jQuery-gMap icon indicating copy to clipboard operation
jQuery-gMap copied to clipboard

Zoom to fit (all markers)

Open nine-2-five opened this issue 12 years ago • 2 comments

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

nine-2-five avatar Dec 11 '12 07:12 nine-2-five

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.

gizmoboy avatar Apr 22 '13 18:04 gizmoboy

I can't understand how to use it

rocchidavide avatar May 25 '16 16:05 rocchidavide