如何将Google Maps API v3中显示的比例更改为英制(英里)单位 [英] How do I change the scale displayed in Google Maps API v3 to imperial (miles) units

查看:105
本文介绍了如何将Google Maps API v3中显示的比例更改为英制(英里)单位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是显示一张地图,没有路线或方向。我可以使用mapOptions = {... scaleControl:true,...}添加控件,但是我找不到有关将标度单位更改为imperial的文档。

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);   

注意:ControlPosition似乎不起作用,总是往右下方。

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

推荐答案

试试这个临时解决方案(这里是一个准备好的函数):

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);

这篇关于如何将Google Maps API v3中显示的比例更改为英制(英里)单位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆