admin管理员组

文章数量:1431398

I have a Google map I created in Javascript using the v3.8 api:

var myOptions = {
      center: map_center,
      panControl: false,
      zoomControl: true,
      scaleControl: true,
      streetViewControl: false,
      mapTypeControlOptions: {
        mapTypeIds: [google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.ROADMAP],
        style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
      }
    };
var map = new google.maps.Map(Dom.get('map_canvas'), myOptions);

But I don't want the label in the maptype control to be 'Satellite', I would like to it to say something else. Any way to do this without doing a custom control like this:

.html#CustomControls

Thanks!

Brian

I have a Google map I created in Javascript using the v3.8 api:

var myOptions = {
      center: map_center,
      panControl: false,
      zoomControl: true,
      scaleControl: true,
      streetViewControl: false,
      mapTypeControlOptions: {
        mapTypeIds: [google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.ROADMAP],
        style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
      }
    };
var map = new google.maps.Map(Dom.get('map_canvas'), myOptions);

But I don't want the label in the maptype control to be 'Satellite', I would like to it to say something else. Any way to do this without doing a custom control like this:

http://code.google./apis/maps/documentation/javascript/controls.html#CustomControls

Thanks!

Brian

Share Improve this question asked Mar 6, 2012 at 20:52 BrianPBrianP 451 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

It is [currently] possible to change the label with

map.mapTypes.satellite.name='NewName';
map.setOptions({'mapTypeControl':true});

The labels need to be set once the map has been initialised, so addListenerOnce on the map's idle event can be used. Example: http://www.acleach.me.uk/gmaps/v3/map-customlabels.htm

I think , there is no way to change labels of mapTypes with Google Maps API (maybe for localization ). So the way I suggest, to create your own menu of mapTypes. Create menu and use menu item's click to call setMapTypeId method of google maps's object.

本文标签: javascriptChanging Google maps 39Satellite label to something else in v38Stack Overflow