Topic: geojson data layer over map

Hey guys,

Im new to unity and to Onlinemaps so im a little unsure with this question but i was wondering if there is a way to import geojson data to overlay the map? Similar to the data layer within google javascript maps, ive posted a link below

https://developers.google.com/maps/docu … /datalayer

if anyone is able to help me with this topic, id really appreciate it!

Regards

Re: geojson data layer over map

Hello.

Example:

using System;
using System.Collections.Generic;
using UnityEngine;

public class GeoJSONExample : MonoBehaviour
{
    private void Start()
    {
        OnlineMapsUtils.GetWWW("https://storage.googleapis.com/mapsdevsite/json/google.json").OnComplete += OnComplete;
    }

    private void OnComplete(OnlineMapsWWW www)
    {
        OnlineMapsJSONItem json = OnlineMapsJSON.Parse(www.text);
        OnlineMapsJSONItem geometries = json["features/*/geometry/coordinates"];
        foreach (OnlineMapsJSONItem geometry in geometries)
        {
            List<double> points = new List<double>();
            foreach (OnlineMapsJSONItem geometryPoints in geometry)
            {
                foreach (OnlineMapsJSONItem point in geometryPoints)
                {
                    points.Add(point[0].Value<double>());
                    points.Add(point[1].Value<double>());
                }
            }
            OnlineMapsDrawingPoly poly = new OnlineMapsDrawingPoly(points, Color.red);
            OnlineMaps.instance.AddDrawingElement(poly);
        }
    }
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: geojson data layer over map

thank you for your help! that worked a treat