bonjour
bonjour

Reputation: 263

How to Set zoom using google map

Need to set the zoom to get all location visible when i have more than one location on map . I am using google map api v3.

The code I am using is below

function initialize() {
    var myLatlng = new google.maps.LatLng(20.798362600000000000, -156.331925299999970000);

    var mapOptions = {
        zoom: 10,
        center: myLatlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };

    map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

    addMarker(21.29539299, -157.8258667,'2525 South King Street,Honolulu HI 96826','Down to Earth','wholesale','restaurant');
    addMarker(20.87521935, -156.68008423,'658 Front St, lahaina HI 96761','Veg Out','wholesale','restaurant');
    addMarker(20.73747253, -156.45561218,'1847 S Kihei Rd,kihei HI 96753','Rodeo Kihei','wholesale','retailer');
    addMarker(20.9165287, -156.38095093,'127 Hana Hwy,Paia HI 96779','Test User','wholesale','retailer');
    addMarker(21.29226112, -157.82328796,'2525 South King Street,Honolulu HI 96826','Some User','wholesale','both');
    addMarker(20.91534615, -156.38002014,'49 Baldwin Ave.,Paia HI 96779','Mana Foods 2','wholesale','retailer');
    addMarker(20.88739586, -156.4566803,'340 Hana Hwy,, HI,Kahului HI 96732','Alive and Well 2','wholesale','restaurant');

    //addMarker(, ,'','','delivery');
}

google.maps.event.addDomListener(window, 'load', initialize);

Upvotes: 0

Views: 67

Answers (1)

blarg
blarg

Reputation: 3893

Change the

  zoom: 10

to a lower number - lower number equals less zoom.

Try: zoom: 5

Example of zoom level 10 :

JSFiddle of Zoom 10

And now zoom level 5:

JSFiddle of Zoom 5

Upvotes: 1

Related Questions