Google maps watchposition { setzoom() } overrides user zooming

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);
            }
        }

Answers


The property 'bounds' on addMarker will override the zoom setting so change it to 'bounds':false


Need Your Help

Is there any single line java command using joda to get seconds in a year?

java jodatime seconds

Is there any single line java command using joda to get seconds in a year?

Loading dynamically pages into div using angularJS

javascript angularjs html

I'm trying to load pages dynamically into a div using a select

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.