Goto Current Location on map

- Added code to auto center to current location
- Change zoom to 8
This commit is contained in:
Yogesh Sharma 2017-07-19 16:39:20 -07:00
parent d4be3b8a25
commit ebc6cb92bf

View File

@ -153,11 +153,29 @@
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(CenterLat, CenterLon),
zoom: 5,
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
infoWindow = new google.maps.InfoWindow;
// Try HTML5 geolocation.
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var pos = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
Map.setCenter(pos);
}, function() {
handleLocationError(true, infoWindow, Map.getCenter());
});
} else {
// Browser doesn't support Geolocation
handleLocationError(false, infoWindow, Map.getCenter());
}
/* Setup our timer to poll from the server. */
window.setInterval(function() {
fetchData();