onsdag den 25. februar 2009

Monkey see, monkey do

Godt så ...

Nice ...


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:

  • GLargeMapControl3D
  • GMapTypeControl
  • GScaleControl

For maps 300 x 400 or smaller, the default controls are:

  • GSmallZoomControl3D
  • GMenuMapTypeControl

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:

  • GLargeMapControl3D, and
  • GSmallZoomControl3D

A full reference of the functions, the GMapUIOptions class and all the defaults are available on the Google Maps API Reference. As always, head over to the forum if you have any questions.

Sorry that puppeteering of John M is not included, but at least now your site can easily look and act like Google Maps!

One more thing: if you want to meet the Maps API team and hear about other exciting things we're working on, come to Google I/O in May.

Read more: http://googlegeodevelopers.blogspot.com/2009/02/posted-by-jez-fletcher-maps-api-team.html

Ingen kommentarer:

Send en kommentar