Ever wanted to be someone else? No, we're not offering a Being John Malkovich service, but we are offering Maps API developers the default look-and-feel of maps.google.com, all with one simple function call.
Now, you can get the standard UI elements you'd see on Google Maps (including the newer style "3D" map and zoom controls), along with other standard behaviour such as keyboard and mouse handling, just by adding one line of code.
// Create a map. var map = new GMap2(myMapDiv); // Give it the maps.google.com experience. map.setUIToDefault();
What's more, this function will ensure that if the UI of maps.google.com changes, these changes will also be reflected in your site without you having to update anything.
The function will automatically adjust what controls the map gets based on the size of the map. For maps larger than 300 x 400, the default controls are:
For maps 300 x 400 or smaller, the default controls are:
Both will also enable scroll wheel zoom, double click zoom and add a
GKeyboardHandler to the map.
You can also tweak the appearance to your liking. If you mostly want the standard behaviour, but, for example, don't want scroll wheel zoom enabled, you can get an instance of the default GMapUIOptions object, and adjust the fields to your liking.
// Get the default GMapUIOptions. var uiOptions = map.getDefaultUI(); // Disable scroll wheel zoom. uiOptions.zoom.scrollwheel = false; // Now set the map's UI with the tweaked options. map.setUI(uiOptions);
Along with this change, you can now also get direct access to the new 3D controls used on maps.google.com:
Sorry that puppeteering of John M is not included, but at least now your site can easily look and act like Google Maps!