Topic: OnMapClick adds a marker to the wrong position
I'm not sure what happened as I'm sure this was working. I have the latest version of online maps v2.5.1.5 and with the following code when I click on screen I get a marker in the wrong position from where I clicked:
private void OnMapClick()
{
double lat;
double lng;
// Get the coordinates where the user clicked.
OnlineMapsControlBase.instance.GetCoords (out lng, out lat);
Debug.Log ("mouse click lat/lon: "+lat+"/"+lng);
OnlineMapsGoogleGeocoding.Find(null, lat+","+lng).OnComplete += delegate(string s)
{
try
{
Vector2 position = OnlineMapsGoogleGeocoding.GetCoordinatesFromResult(s);
if (position != Vector2.zero) _marker = OnlineMaps.instance.AddMarker(position,"");
else Debug.Log(s);
}
catch
{
Debug.Log(s);
}
};
}
The marker lands close, but it's very random as to where it lands in relation to where I've clicked. I'm using OpenStreetMap zoom 14 with Tileset. I have already tried the GetCoord() using the Vector2 rather than double. Do you see anything wrong with this code? Does it sound like something you've seen before? What could I be doing wrong?
EDIT: Added more details above.
Thanks