Here is my code without classes:
var map = null; var ERROR_MESSAGES = { GPS_OFF: "please turn on GPS from your settings.", GPS_TIME_OUT: "maybe you are in a building or something, get into an open area.", GPS_UNKOWN: "Error happened while getting location, please try again later." }; var geolocationManager = new GeolocationManager(); function success(position) { var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); var options = { zoom: 18, center: coords, mapTypeControl: false, disableDefaultUI: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.SMALL }, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("mapcontainer"), options); var marker = new google.maps.Marker({ position: coords, map: map, icon:'e-pin.png', animation:google.maps.Animation.BOUNCE }); } function findPosition(onSuccess) { geolocationManager.isLocationEnabled(function (isEnabled) { if (!isEnabled) { Util.Alert(ERROR_MESSAGES.GPS_OFF); return; } geolocationManager.find(onSuccess, function (e) { Util.Alert(ERROR_MESSAG`enter code here`ES.GPS_UNKOWN); }); }, function (e) { geolocationManager.find(onSuccess, function (e) { Util.Alert(ERROR_MESSAGES.GPS_UNKOWN); }); }); } function watchPosition () { geolocationManager.watch(); } findPosition(success); function getLocation() { if (!map) findPosition(success); else findPosition(showPosition); } function setCurrentPosition() { findPosition(function (position) { var coords = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); map.panTo(coords); }); } function showPosition(position) { map.setCenter(new google.maps.LatLng(position.coords.latitude,position.coords.longitude)); }
source share