embed - Center and auto zoom google map -
;)
i'm not familiar google maps api yet able figure out questions beginners faults. ;) don't center map between 2 markers set , auto zoom it... ;(
maybe has right hint me...
thanks , cheers!
<script> function initialize() { var mylatlng = new google.maps.latlng(0, 0); var mapoptions = { zoom: 3, maptypecontrol: false, navigationcontrol: false, scrollwheel: false, streetviewcontrol: false, zoomcontrol: false, center: mylatlng, maptypeid: google.maps.maptypeid.terrain }; var map = new google.maps.map(document.getelementbyid('map'), mapoptions); var flightplancoordinates = [ new google.maps.latlng(100, 100), new google.maps.latlng(120, 120) ]; var linesymbol = { path: google.maps.symbolpath.forward_closed_arrow }; var flightpath = new google.maps.polyline({ path: flightplancoordinates, geodesic: true, strokecolor: '#ff0000', strokeopacity: 0.5, icons: [{ icon: linesymbol, offset: '100%' }], strokeweight: 2 }); flightpath.setmap(map); } google.maps.event.adddomlistener(window, 'load', initialize);</script> <div id="map" style="width: 100%; height: 300px"></div>
<script>jquery('#mymodal-<? the_id(); ?>').on('shown', function () { google.maps.event.trigger(map, 'resize'); map.setcenter(new google.maps.latlng(42.3605336, -72.6362989)); })</script>
you need fit bounds of map pertains markers.
// make array of latlng's of markers want show var latlnglist = new array (new google.maps.latlng (52.537,-2.061), new google.maps.latlng (52.564,-2.017)); // create new viewpoint bound var bounds = new google.maps.latlngbounds (); // go through each... (var = 0, ltlglen = latlnglist.length; < ltlglen; i++) { // , increase bounds take point bounds.extend (latlnglist[i]); } // fit these bounds map map.fitbounds (bounds);
Comments
Post a Comment