0
Beantwoord

How to zoom map to current location

Luska72 10 jaar geleden bijgewerkt door icahill (Administrator) 10 jaar geleden 2
Hello, I was wondering if it is possible to create a map, and have it zoom into the user's current location. I have tried the <assign property> for the region of the map, but I have had no successes.
Thank you for your time,
Luska72
Yes this is pretty easy to do, however you have to balance when the map finds your GPS location and then zoom into that location after the fact. 

Here is a sample:

<wire>
   <main>
       <panel name="test" width="100%" height="100%" >
         <map name="map" alias="MAP" width="100%" height="100%" type="satelite"></map>
       </panel>
   </main>
   <actions>
     <action name="zoom" oninit="yes">
       <assign property="object:MAP.showuser" value="yes"/>
      <sync delay="1">   
       <play action="region" />   
      </sync>    
     </action>
     <action name="region">
     	<assign property="object:MAP.region" value="[object:MAP.gpslatitude] [object:MAP.gpslongitude] [object:MAP.gpslatitude] [object:MAP.gpslongitude]"/>
     </action>  
   </actions>
</wire>
Thank you, it works very well!