2009年4月4日 星期六

ym4r memo(2)

ym4r in github

GMarkerGroup
To use it you would have to include in your HTML template the JavaScript file markerGroup.js after the call
to GMap.header (because it extends the GOverlay class).
You should have something like that in your
template:
<%= javascript_include_tag("markerGroup") %>

It is useful in 2 situations:
- Display and undisplay a group of markers without referencing all of them. You just declare your marker group globally and call +activate+ and +deactivate+ on this group in response, for example, to clicks on links on your page. - Keeping an index of markers, for example, in order to show one of these markers in reponse to a click on a link (the way Google Local does with the results of the search).

還有其他function 都在 public/javascript 的markerGroup.js 裡面還有更多其他有用的function
You can call +activate+ and +deactivate+ to display or undisplay a group of markers. You can add new markers with addMarker(marker,id). Again if you don't care about referencing the marker, you don't need to pass an id. If the marker group is active, the newly added marker will be displayed immediately. Otherwise it will be displayed the next time the group is activated. Finally, since it is an overlay, the group will be removed when calling clearOverlays on the GMap object.

You can center and zoom on all the markers in the group by calling GMarkerGroup#centerAndZoomOnMarkers() after the group has been added to a map. So for example, if you would want to do that at initalization time, you would do the following assuming your marker group has been declared as +group+): @map.record_init group.center_and_zoom_on_markers

沒有留言: