Hey guys I’ve finally got my google maps working the way I want it, but I don’t want my zoom to prevent the user from zooming in themselves (this keeps resetting it), I put a conditional on my setZoom to only get it to fire on first watchposition() but if I do that then the the maps sits at maximum zoom for some reason.
function CreateMap() {
var zoomWithoutLatLng = 13;
var zoomWithLatLng = 15;
Data.$paymentMap.gmap({'center': GetLatLng(), 'zoom' : zoomWithoutLatLng}).bind('init', function(evt, map) {
Data.$paymentMap.gmap('watchPosition', function(position, status) {
if (status === 'OK') {
Data.$paymentMap.gmap({'zoom' : zoomWithLatLng});
var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
var userMarker = Data.$paymentMap.gmap('get', 'markers > user' );
if (!userMarker) {
Data.$paymentMap.gmap('addMarker', { 'id': 'user', 'position': GetLatLng(), 'bounds': true) });
} else {
userMarker.setPosition(latlng);
map.panTo(latlng);
}
}
});
});
}
function GetLatLng() {
if (google.loader.ClientLocation != null) {
return new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
}
}
The property ‘bounds’ on addMarker will override the zoom setting so change it to ‘bounds’:false