13

I suspect part of my problem is that I'm having a mental freeze on what the technical name for this is: But you see on http://maps.google.co.uk/ the bottom left has a small ruler indicating how big x Miles is at the current zoom level?

If I'm using google Maps API version 2, how do I add such a wonderful do-hickery widget thing to my website maps?

Thanks, James

1

3 Answers 3

47

Actually this is how you really get the scale to show:

var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, scaleControl: true, center: new google.maps.LatLng(-33.92, 151.25), mapTypeId: google.maps.MapTypeId.ROADMAP }); 
Sign up to request clarification or add additional context in comments.

Comments

-2

From the API docs:

GScaleControl - a map scale 

1 Comment

Knew it'd be called something obvious :-)
-3

I found that if you call the map as a function rather than as var and apply the scaleControl as suggested, the entire map fails to show. Still working on a solution that solves this part of the problem.

function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: 15.5, lng: 121}, zoom: 10 }); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.