<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — OnMapClick adds a marker to the wrong position]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=384&amp;type=atom" />
	<updated>2017-01-13T15:15:11Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=384</id>
		<entry>
			<title type="html"><![CDATA[Re: OnMapClick adds a marker to the wrong position]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=1678#p1678" />
			<content type="html"><![CDATA[<p>Hello</p><p>Your original code did not work properly, because you send the coordinates to Google Geocoding API for reverse geocoding.<br />This service searches for information about the place by coordinates (approximate). <br />Usually it sticks to buildings, roads, etc. <br />So coordinate returned by this service can differ from coordinates of the request.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-01-13T15:15:11Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=1678#p1678</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: OnMapClick adds a marker to the wrong position]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=1677#p1677" />
			<content type="html"><![CDATA[<p>In doing some research I have found the following from a different thread on this forum, and it worked perfectly.&nbsp; </p><p>&nbsp; &nbsp; private void OnMapClick()<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; Vector2 coords = OnlineMapsControlBase.instance.GetCoords();<br />&nbsp; &nbsp; &nbsp; &nbsp; OnlineMaps.instance.AddMarker(coords);<br />&nbsp; &nbsp; &nbsp; &nbsp; points.Add(coords);<br />&nbsp; &nbsp; &nbsp; &nbsp; if (points.Count == 2) OnlineMaps.instance.AddDrawingElement(new OnlineMapsDrawingLine(points, Color.red, 3));<br />&nbsp; &nbsp; }</p><br /><p>Now this makes me wonder by my original implementation was so convoluted.&nbsp; All I ever wanted was the latitude and longitude for where the user clicked.&nbsp; My OP was what I came up with after searching the examples and docs, so clearly when I think I know how to use this asset, I really don&#039;t.</p>]]></content>
			<author>
				<name><![CDATA[digitalrock]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=308</uri>
			</author>
			<updated>2017-01-13T00:42:14Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=1677#p1677</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[OnMapClick adds a marker to the wrong position]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=1675#p1675" />
			<content type="html"><![CDATA[<p>I&#039;m not sure what happened as I&#039;m sure this was working.&nbsp; 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:</p><p>&nbsp; &nbsp; private void OnMapClick()<br />&nbsp; &nbsp; {</p><p>&nbsp; &nbsp; &nbsp; &nbsp; double lat;<br />&nbsp; &nbsp; &nbsp; &nbsp; double lng;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // Get the coordinates where the user clicked.<br />&nbsp; &nbsp; &nbsp; &nbsp; OnlineMapsControlBase.instance.GetCoords (out lng, out lat);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; Debug.Log (&quot;mouse click lat/lon: &quot;+lat+&quot;/&quot;+lng);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; OnlineMapsGoogleGeocoding.Find(null, lat+&quot;,&quot;+lng).OnComplete += delegate(string s)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Vector2 position = OnlineMapsGoogleGeocoding.GetCoordinatesFromResult(s);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (position != Vector2.zero) _marker = OnlineMaps.instance.AddMarker(position,&quot;&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else Debug.Log(s);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Debug.Log(s);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; };<br />&nbsp; &nbsp; }</p><p>The marker lands close, but it&#039;s very random as to where it lands in relation to where I&#039;ve clicked.&nbsp; I&#039;m using OpenStreetMap zoom 14 with Tileset.&nbsp; I have already tried the GetCoord() using the Vector2 rather than double.&nbsp; &nbsp;Do you see anything wrong with this code?&nbsp; Does it sound like something you&#039;ve seen before?&nbsp; &nbsp;What could I be doing wrong?</p><p>EDIT:&nbsp; Added more details above.</p><br /><p>Thanks</p>]]></content>
			<author>
				<name><![CDATA[digitalrock]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=308</uri>
			</author>
			<updated>2017-01-12T20:17:44Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=1675#p1675</id>
		</entry>
</feed>
