2 //thx @elroyjetson for the code example
4 // When map page opens get location and display map
5 $('.page-map').live("pagecreate", function() {
11 //try to get GPS coords
12 if( navigator.geolocation ) {
14 //redirect function for successful location
15 function gpsSuccess(pos){
17 lat = pos.coords.latitude;
18 lng = pos.coords.longitude;
27 //Geo-location is supported, but we failed to get your coordinates. Workaround here perhaps?
30 navigator.geolocation.getCurrentPosition(gpsSuccess, gpsFail, {enableHighAccuracy:true, maximumAge: 300000});
34 if not supported, you might attempt to use google loader for lat,long
35 $.getScript('http://www.google.com/jsapi?key=YOURAPIKEY',function(){
36 lat = google.loader.ClientLocation.latitude;
37 lng = google.loader.ClientLocation.longitude;
41 var latlng = new google.maps.LatLng(lat, lng);
45 mapTypeId: google.maps.MapTypeId.ROADMAP
47 var map = new google.maps.Map(document.getElementById("map-canvas"),myOptions);