Callbacks
Because interactive maps involve user events and asynchronous processing, all map providers make extensive use of callbacks. MyMapGeocode uses a callback to get the geocoding result.
Google and Yahoo let you handle callbacks using a dedicated class (GEvent or YEvent). This class is responsible for registering all callbacks for an object like a map or a marker.
Example 1(a) shows how to create a callback with Google Maps. The method GEvent.addListener is used to associate an object, an event name, and a function to call for that event. Google Maps calls at runtime the registered function of the appropriate object when this event is raised.
(a) GEvent.addListener(object, eventname, callback); (b) YEvent.Capture(object, EventsLists.value, callback);
Example 1(b) shows callback creation in Yahoo Maps. The process is similar to the Google one except that we use an event enumeration instead of an event name.
There is no concept of callback registration in Virtual Earth. Each function directly takes a callback as a parameter when needed. The drawback is that you can't choose which event to useyou are limited to the event the designer of the method chose.
Markers
Again, Google Maps and Yahoo Maps are similar for markers creation. You create an icon object (GIcon/YImage), and then create a marker object (GMarker/YMarker) to hold the marker data. If you want a tooltip to be displayed when the marker is clicked, you simply register a callback on the click event as previously explained.
Virtual Earth uses a single object for the whole process. You need to build a VEPushPin object with an image and some text for the tooltip. It's not possible to choose the triggering event. You can also call custom code neither before nor after the tooltip is displayed.
To avoid icon file handling, MyMap uses the same image for all map providers. You just need to specify a "marker type" constant, which is mapped to a specific icon.
Because all providers support HTML tags in the tooltip text, you can customize your description using formatting, images, or links.
Zoom
Hopefully, zoom levels for all map providers have nearly the same range:
- From 0 to 19 for Google Maps.
- From 1 to 16 for Yahoo Maps.
- From 1 to 19 for Virtual Earth.
Furthermore, the same zoom level gives the same map scale for all providers. It can't be luck!
A slight difference for Yahoo Maps is that zoom levels are inverted: 1 is the higher zoom, 16 is the lower. The MyMapSetZoom function in mymap_yahoo.js does a difference to 18 on its parameter, so you can keep the same function call regardless of which provider you use.