<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — OnMapClick adds a marker to the wrong position]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=384</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=384&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in OnMapClick adds a marker to the wrong position.]]></description>
		<lastBuildDate>Fri, 13 Jan 2017 15:15:11 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: OnMapClick adds a marker to the wrong position]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1678#p1678</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 13 Jan 2017 15:15:11 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1678#p1678</guid>
		</item>
		<item>
			<title><![CDATA[Re: OnMapClick adds a marker to the wrong position]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1677#p1677</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (digitalrock)]]></author>
			<pubDate>Fri, 13 Jan 2017 00:42:14 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1677#p1677</guid>
		</item>
		<item>
			<title><![CDATA[OnMapClick adds a marker to the wrong position]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1675#p1675</link>
			<description><![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>]]></description>
			<author><![CDATA[null@example.com (digitalrock)]]></author>
			<pubDate>Thu, 12 Jan 2017 20:17:44 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1675#p1675</guid>
		</item>
	</channel>
</rss>
