2

オーバーラップ マーカー SpiderfierおよびMarkerWithLabelで Google Maps JavaScript API v3 を使用すると、spiderfying 時に悪影響があります。最初のマーカーを除いて、すべてのマーカーは Spiderfy を実行した後、すぐに元の位置に戻ります ( unspiderfy 経由ではありません)。

つまり、Spiderfying の後に、Marker イベントposition_changedがさらに 1 回トリガーされます。n - 1n

ここに画像の説明を入力

4

1 に答える 1

1

この問題は、optimizedMarkerWithLabel が false に強制する Marker 属性に起因します。true optimized(デフォルト設定) のままにしておくと、正しいスパイダーファイリングが行われます。これを行うには、 MarkerWithLabel ソースへのパッチが必要ですが、設定されている行を削除しますoptimized = false

function MarkerWithLabel(opt_options) {
  opt_options = opt_options || {};
  opt_options.labelContent = opt_options.labelContent || "";
  opt_options.labelAnchor = opt_options.labelAnchor || new google.maps.Point(0, 0);
  opt_options.labelClass = opt_options.labelClass || "markerLabels";
  opt_options.labelStyle = opt_options.labelStyle || {};
  opt_options.labelInBackground = opt_options.labelInBackground || false;
  if (typeof opt_options.labelVisible === "undefined") {
    opt_options.labelVisible = true;
  }
  if (typeof opt_options.raiseOnDrag === "undefined") {
    opt_options.raiseOnDrag = true;
  }
  if (typeof opt_options.clickable === "undefined") {
    opt_options.clickable = true;
  }
  if (typeof opt_options.draggable === "undefined") {
    opt_options.draggable = false;
  }
  // if (typeof opt_options.optimized === "undefined") {
  //   opt_options.optimized = false;
  // }
  opt_options.crossImage = opt_options.crossImage || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/drag_cross_67_16.png";
  opt_options.handCursor = opt_options.handCursor || "http" + (document.location.protocol === "https:" ? "s" : "") + "://maps.gstatic.com/intl/en_us/mapfiles/closedhand_8_8.cur";
  // opt_options.optimized = false; // Optimized rendering is not supported

  this.label = new MarkerLabel_(this, opt_options.crossImage, opt_options.handCursor); // Bind the label to the marker

  // Call the parent constructor. It calls Marker.setValues to initialize, so all
  // the new parameters are conveniently saved and can be accessed with get/set.
  // Marker.set triggers a property changed event (called "propertyname_changed")
  // that the marker label listens for in order to react to state changes.
  google.maps.Marker.apply(this, arguments);
}

ここに画像の説明を入力

于 2014-11-24T20:54:53.597 に答える