Basically I am trying to determine how to set the auto scaling and auto center function for my #map_div div. But since my markers are dynamically generated, somehow I need the zoom and center to work automatically based on the width and height of my #map_div
But as you can see in my gmap3 script that I have to determine the scale and center manually, and not cool.
I found this script fragment below, but I canโt see how to associate it with my .gmap3 script. Is there any way to integrate it with my .gmap3 jquery script plugin?
Calculation of the center point var ...
// map: an instance of google.maps.Map object // latlng: an array of google.maps.LatLng objects var latlngbounds = new google.maps.LatLngBounds( ); for ( var i = 0; i < latlng.length; i++ ) { latlngbounds.extend( latlng[ i ] ); } map.fitBounds( latlngbounds );
Found above script here
My .gmap3 script below ...
jQuery(function($) { $('#map_div').gmap3({ action: 'init', options: { center: [50.799019, -1.132037], zoom: 5, scrollwheel: false } }, { action: 'addMarkers', markers: [{ lat: 50.799019, lng: -1.132037, data: 'Test One'}, { lat: 50.365162, lng: -4.712017, data: 'Test Two'}, { lat: 54.518726, lng: -5.881054, data: 'Test Three'}, { lat: 52.780964, lng: -1.211863, data: 'Test Four'}, { lat: 51.433998, lng: -2.549690, data: 'Test Five' }], marker: { options: { draggable: false } } }); });
I usually do jsfiddle, but the site is down.
Any help with this would be so great.