Google Maps API Type Control

In 2018 Google suddenly raised the pricing on the Maps API by more than 10x. In order to enforce this they also intentionally crippled the standard map-type control widget to keep users from switching to a non-Google map type. This control is a non-crippled replacement for the standard one. Try it out in this sample map:

Using the Type Control

The control is written to be mostly independent of other files, so you can easily drop it into any Google Maps API v3 map. Start by loading the code into your HTML file:


<script src="//acme.com/javascript/acme.namespace.jsm" type="text/javascript"></script>
<script src="//acme.com/javascript/acme.maps_g3.typecontrol.jsm" type="text/javascript"></script>
    

If you want to copy the code to your own site that's fine - trade-off between depending on me vs. getting any bugfixes.

Step two, after you have set up all your map types, add the control to your map. Pass in the same mapOptions you used to create the map.


acme.maps_g3.typecontrol.Add( map, mapOptions );
    

That's all there is to it. The widget automatically turns off the standard map type control and replaces it in the same position with the same map types.


ACME Labs / JavaScript Utilities / Type Control
email