<?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 — Unable to get map to move/zoom to current location on start / anytime]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=2075</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2075&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Unable to get map to move/zoom to current location on start / anytime.]]></description>
		<lastBuildDate>Fri, 30 Dec 2022 10:20:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Unable to get map to move/zoom to current location on start / anytime]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8799#p8799</link>
			<description><![CDATA[<p>Hello.</p><p>Use OnlineMaps.SetPositionAndZoom.<br /><a href="https://infinity-code.com/doxygen/online-maps/classOnlineMaps.html#a16487b43906676020435e33675112887">https://infinity-code.com/doxygen/onlin … 3675112887</a></p><p>Something like:<br /></p><div class="codebox"><pre><code>var lastData = Input.location.lastData;
OnlineMaps.instance.SetPositionAndZoom(lastData.longitude, lastData.latitude, SOME_ZOOM);</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 30 Dec 2022 10:20:23 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8799#p8799</guid>
		</item>
		<item>
			<title><![CDATA[Unable to get map to move/zoom to current location on start / anytime]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8798#p8798</link>
			<description><![CDATA[<p>Hi,</p><p>I am using the below script attached to an object on my application, which grabs the users current location, but I cam not able to get the Map to move to this position and zoom in a little when the application opens. I also save the position to a playerpref item and use that to speed up the process on start with the Latitude and Longititude coords.</p><p>I have tried to implement this with the <a href="http://infinity-code.com/atlas/online-maps/pages/SmoothMoveExample.html">http://infinity-code.com/atlas/online-m … ample.html</a> but it just does not go anywhere or move on start.</p><p>Is there a better example on how to do this? I am also going to try to implement a second / third marker into the map for other users positions so maybe something than can incorporate that also? I have seen the tutorial youtube v=Yl5K_Wr6Umk so that might work, but the initial location go to and zoom is my main issue at the moment.</p><br /><p>SCRIPT for getting location of mobile user<br />==========================<br />using System.Collections;<br />using UnityEngine;<br />using UnityEngine.UI;<br />using UnityEngine.Android;</p><p>public class GPS : MonoBehaviour<br />{<br />&nbsp; &nbsp; public Text gpsOut;<br />&nbsp; &nbsp; public bool isUpdating;<br />&nbsp; &nbsp; private void Update()<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if (!isUpdating)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StartCoroutine(GetLocation());<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isUpdating = !isUpdating;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; IEnumerator GetLocation()<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; if (!Permission.HasUserAuthorizedPermission(Permission.FineLocation))<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Permission.RequestUserPermission(Permission.FineLocation);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Permission.RequestUserPermission(Permission.CoarseLocation);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; // First, check if user has location service enabled<br />&nbsp; &nbsp; &nbsp; &nbsp; if (!Input.location.isEnabledByUser)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield return new WaitForSeconds(10);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // Start service before querying location<br />&nbsp; &nbsp; &nbsp; &nbsp; Input.location.Start();</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // Wait until service initializes<br />&nbsp; &nbsp; &nbsp; &nbsp; int maxWait = 10;<br />&nbsp; &nbsp; &nbsp; &nbsp; while (Input.location.status == LocationServiceStatus.Initializing &amp;&amp; maxWait &gt; 0)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield return new WaitForSeconds(1);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; maxWait--;<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // Service didn&#039;t initialize in 20 seconds<br />&nbsp; &nbsp; &nbsp; &nbsp; if (maxWait &lt; 1)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gpsOut.text = &quot;Timed out&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;Timed out&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield break;<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // Connection has failed<br />&nbsp; &nbsp; &nbsp; &nbsp; if (Input.location.status == LocationServiceStatus.Failed)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gpsOut.text = &quot;Unable to determine device location&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;Unable to determine device location&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield break;<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; else<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gpsOut.text = &quot;Location: &quot; + Input.location.lastData.latitude + &quot; &quot; + Input.location.lastData.longitude + &quot; &quot; + Input.location.lastData.altitude + 100f + &quot; &quot; + Input.location.lastData.horizontalAccuracy + &quot; &quot; + Input.location.lastData.timestamp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Access granted and location value could be retrieved<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(&quot;Location: &quot; + Input.location.lastData.latitude + &quot; &quot; + Input.location.lastData.longitude + &quot; &quot; + Input.location.lastData.altitude + &quot; &quot; + Input.location.lastData.horizontalAccuracy + &quot; &quot; + Input.location.lastData.timestamp);<br />&nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; // Stop service if there is no need to query location updates continuously<br />&nbsp; &nbsp; &nbsp; &nbsp; isUpdating = !isUpdating;<br />&nbsp; &nbsp; &nbsp; &nbsp; Input.location.Stop();<br />&nbsp; &nbsp; }<br />}</p><p>END SCRIPT</p>]]></description>
			<author><![CDATA[null@example.com (thorntonp72)]]></author>
			<pubDate>Fri, 30 Dec 2022 04:06:28 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8798#p8798</guid>
		</item>
	</channel>
</rss>
