Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Zoom to fit (all markers) #5

Open
nine-2-five opened this issue Dec 11, 2012 · 2 comments
Open

Zoom to fit (all markers) #5

nine-2-five opened this issue Dec 11, 2012 · 2 comments

Comments

@nine-2-five
Copy link

Is there an option to set the zoom level to auto, so it shows all markers (let's say in a city)?

@gizmoboy
Copy link

I extended the code with this implementation:

        // Zoom it fit markers
        $(this).bind('gMap.zoomToFitMarkers', function () {
            if (overlays && overlays.length > 0) {
                var bounds = new google.maps.LatLngBounds();

                for (var i = 0; i < overlays.length; i++) {
                    bounds.extend(overlays[i].getPosition());
                }

                $gmap.fitBounds(bounds);
            }
        });

You also need to add this to the case at the top:

        case 'zoomToFitMarkers':
            return $(this).trigger('gMap.zoomToFitMarkers');

Tried to clone so I could submit a pull request, but gitHub for Windows keeps failing to clone.

@rocchidavide
Copy link

I can't understand how to use it

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

No branches or pull requests

3 participants