takhamo123 / jquery-ui-map

Automatically exported from code.google.com/p/jquery-ui-map
0 stars 0 forks source link

Map zoom out when updating with new location #87

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I'm not sure if it's plugin issue or Google map. When i update map with new 
coordinates, map zoom out. Following is the code 

        $( document ).on( "pageinit", "#page-3", function( event ) {
            var newPoint = new google.maps.LatLng(current_lat, current_lon);
            //google_map.gmap({ 'center': newPoint, 'zoom': 10 });

                google_map.gmap({'center': newPoint, 'zoom': 12, scrollwheel:false, 'disableDefaultUI':true,'callback': function() {
                    var self = this;
                    //google_map.gmap('addControl', 'sidebar', google.maps.ControlPosition.LEFT_TOP);

                    self.set('getCurrentPosition', function() {
                        self.refresh();
                        self.getCurrentPosition( function(position, status) {
                            if ( status === 'OK' ) {
                                var latlng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude)
                                self.get('map').panTo(latlng);
                                self.search({ 'location': latlng }, function(results, status) {
                                    if ( status === 'OK' ) {
                                        //$('#from').val(results[0].formatted_address);
                                    }
                                });
                            } else {
                                alert('Unable to get current position');
                            }
                        });
                    });

                }});

        });

        $( document ).on( "pageshow", "#page-3", function( event ) {

            google_map.gmap('get', 'getCurrentPosition');
            google_map.gmap('refresh');
        });

//When click on detail page, it reload map with new coordinates

                var from = new google.maps.LatLng(current_lat,current_lon);
                var to = new google.maps.LatLng(coordinates[0], coordinates[1]);

                google_map.gmap('displayDirections',{ 'origin': from, 'destination': to, 'travelMode': google.maps.DirectionsTravelMode.DRIVING }, { 'panel': document.getElementById('directions')}, function(response, status) {

                    google_map.gmap({'zoom': 12, scrollwheel:false});

                });

Original issue reported on code.google.com by asif.kil...@gmail.com on 5 Nov 2014 at 7:33