Google Maps API Tutorial© 2006, 2007, 2009 Mike Williams |
Translate this page: |
Using the EWindow extensionThe EWindow extension provides some of the functionality of custom info windows.Here's an example with a single EWindow that behaves something like the Google info window. Here's a similar example but now the EWindow has a close icon. Here's an example with multiple info windows that are permanently open. The basic procedure for using EWindows is:
EWindow ConstructorThe parameters for new EWindow() are:
Opening an EWindowThere are two methods provided for opening an EWindowewindow.openOnMap
This opens the EWindow on the map that you specified in the EWindow constructor.
ewindow.openOnMarker This opens the EWindow on the map that you specified in the EWindow constructor, with a location derived from the specified marker.
This call uses the infoWindowAnchor parameter of the icon that is being used by the marker.
Multiple EWindowsYou can have as many EWindows as you like on the same map. Use the EWindow constsuctor to construct them ewindow2 = new EWindow(map, E_STYLE_1); map.addOverlay(ewindow2);Closing an EWindowUse ewindow.hide()There's no close icon in an EWindow, so you might consider arranging for them to close when the user clicks on the map // ========== Close the EWindow if theres a map click ========== GEvent.addListener(map, "click", function(marker,point) { if (point) { ewindow.hide(); } });map.removeOverlay(ewindow) is provided because it's a required part of the Custom Overlay interface, but I don't recommend using it. You can use ewindow.show() to unhide an EWindow. EWindow.copy()ewindow.copy() is provided because it's a required part of the Custom Overlay interface, but the copy will not be visible uless you use .openOnMap() or .openOnMarker() on the copy. So, for example, the EWindow will not be visible in blowups.Making your own EStylesIf you don't like the EStyles that are provided, you can make your own.Create a suitable image for the stem. To keep things reasonably simple, the anchor point is always the bottom left corner of the stem image.
Then use the EStyle constructor like this The parameters are:
If you create some nice EStyles that other people could use, send me a copy and I'll include them in the EWindow distribution. |