Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map zoom out when updating with new location #87

Open
GoogleCodeExporter opened this issue Nov 27, 2015 · 0 comments
Open

Map zoom out when updating with new location #87

GoogleCodeExporter opened this issue Nov 27, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

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 [email protected] on 5 Nov 2014 at 7:33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant