Marker Manager Examples-GoogleMaps/API/doc/MarkerManagerExamples-N☆E 学習帳

[ リロード ]   [ ソース ]  [ トップ | 一覧 | 単語検索 | 最新 | バックアップ | ヘルプ ]

Counter: 3679, today: 1, yesterday: 2

Marker Manager Examples

http://www.google.com/apis/maps/docu­mentation/

Version 2 (2006.11)

To use a marker manager, create a GMarkerManager object. In the simplest case, just pass a map to it.

var map = new GMap2(document.getElementById("map"));
var mgr = new GMarkerManager(map);

You may also specify a number of options to fine-tune the marker manager's performance. These options are passed via a GMarkerManagerOptions object, which contains the following fields:

  • maxZoom: specifies the maximum zoom level monitored by this marker manager. The default value is the highest zoom level supported by Google maps.
  • borderPadding: specifies the extra padding, in pixels, monitored by the manager outside the current viewport. This allows for markers just out of sight to be displayed on the map, improving panning over small ranges. The default value is 100.
  • trackMarkers: specifies whether movement of movements of markers should be tracked by the marker manager. If you wish to have managed markers that change their positions through the setPoint() method, set this value to true. By default, this flag is set to false. Note that if you move markers with this value set to false, they will appear in both the original location and the new location(s).

The GMarkerManagerOptions object is an object literal, so you simply declare the object without a constructor:

var map = new GMap2(document.getElementById("map"));
var mgrOptions = { borderPadding: 50, maxZoom: 15, trackMarkers: true };
var mgr = new GMarkerManager(map, mgrOptions);

Once you create a manager, you will want to add markers to it. GMarkerManager supports adding single markers one at a time using the addMarker() method or a collection passed as an array using the addMarkers() method. Single markers added using addMarker() will appear immediately on the map provided that they fall within the current view and specified zoom level constraints.

Adding markers collectively using addMarkers() is recommended as it is more efficient. Markers added using the addMarkers() method will not appear on the map until you explicitly call the GMarkerManager's refresh() method, which adds all markers within the current viewport and border padding region to the map. After this initial display, GMarkerManager takes care of all visual updates by monitoring the map's "moveend" events.