Skip to content

Instantly share code, notes, and snippets.

@brnkhy
Created June 21, 2017 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brnkhy/dcff0ba425303a69b995296a90dea4fe to your computer and use it in GitHub Desktop.
Save brnkhy/dcff0ba425303a69b995296a90dea4fe to your computer and use it in GitHub Desktop.
AddPoi.cs
using Mapbox.Unity.Map;
using Mapbox.Unity.Utilities;
using Mapbox.Utils;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AddPoi : MonoBehaviour
{
public AbstractMap Map;
public List<string> Coordinates;
void Start()
{
Map.OnInitialized += () =>
{
foreach (var item in Coordinates)
{
var latLonSplit = item.Split(',');
var llpos = new Vector2d(double.Parse(latLonSplit[0]), double.Parse(latLonSplit[1]));
var pos = Conversions.GeoToWorldPosition(llpos, Map.CenterMercator, Map.WorldRelativeScale);
var gg = GameObject.CreatePrimitive(PrimitiveType.Sphere);
gg.transform.position = new Vector3((float)pos.x, 0, (float)pos.y);
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment