Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Nice question. I faced a similar problem before. But, later, I figured out the solution.</p> <p>Here's how you can solve it.</p> <ul> <li>Either use <a href="http://docs.phonegap.com/en/1.6.1/cordova_geolocation_geolocation.md.html#Geolocation" rel="nofollow"><strong>Phonegap's Geolocation API</strong></a> or ..</li> <li>Use <a href="http://localhost/sencha/docs/#!/api/Ext.util.Geolocation" rel="nofollow"><strong>Ext.util.Geolocation</strong></a> from Sencha Touch API</li> </ul> <p>Demo with <strong>Phonegap's Geolocation API</strong></p> <ol> <li><p>Get the geolocation via the geolocation api.</p> <pre><code>vat lat, lng; var geoLocationOptions = { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true }; navigator.geolocation.getCurrentPosition(geoLocationSuccess,geoLocationError,geoLocationOptions); function geoLocationSuccess(position) { lat = position.coords.latitude; lng = position.coords.longitude; Ext.Msg.alert("Geolocation","Latitude:"+ lat +", Longitude:"+ lng); } function geoLocationError() { Ext.Msg.alert('Error','Error while getting geolocation'); } </code></pre></li> <li><p>Then use the values of lat and lng to set the map's center to it as well as set the marker's position to that value.</p> <pre><code> ... ... var position = new google.maps.LatLng(lat,lng); map = this.add({ xtype: 'map', getLocation: true, autoLoad: true, mapOptions: { zoom: 15, center: position, mapTypeId: google.maps.MapTypeId.ROADMAP, navigationControl: true, zoomControl: true, mapTypeControl: true, scrollwheel: true, scaleControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.LARGE } } }); marker = new google.maps.Marker({ id: 'geoLocMarker', position: position, map: map.getMap(), visible: true }); ... ... </code></pre></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload