Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the scale displayed in Google Maps API v3 to imperial (miles) units

I'm simply displaying a map, with no routing or directions. I can add the control with mapOptions = {...scaleControl: true,...} but I could find no documentation about changing the units of the scale to imperial.

Here's my code:

var mapOptions = {
    zoom: 4,
    mapTypeControl: false,
    center: new google.maps.LatLng(38.8282, -98.5795),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    scaleControl: true,
    scaleControlOptions: {position: google.maps.ControlPosition.BOTTOM_LEFT}
};
google.maps.visualRefresh = true;

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

Note: The ControlPosition appears not to work, always goes to bottom right.

like image 509
James Bell Avatar asked Aug 05 '13 21:08

James Bell


People also ask

How do you change the scale legend units on Google Earth?

Simply go to the View menu and click Scale Legend> The scale will change constantly as you zoom in and out.


1 Answers

Try this temp solution (here it is in a ready function):

var scaleInterval = setInterval(function() {
  var scale = $(".gm-style-cc:not(.gmnoprint):contains(' km')");
  if (scale.length) {
    scale.click();
    clearInterval(scaleInterval);
  }
}, 100);
like image 56
Memory Leak Avatar answered Sep 19 '22 14:09

Memory Leak