0

我在使用第二个 CustomMarker 时遇到问题。我可以在地图上看到路径,但我的自定义图像没有显示锚点。我错过了什么?

我的第二个自定义标记的代码是:

/* ***** Begin CustomMarker Toekomst ***** */
function CustomMarkerToekomst(latlng, map, marker_id, hovercard) {
  this.latlng_ = latlng;
  this.marker_id = marker_id;
  this.hovercard_content = hovercard;
  this.setMap(map);
}

CustomMarkerToekomst.prototype = new google.maps.OverlayView();

CustomMarkerToekomst.prototype.draw = function() {
  var me = this;
  var div = this.div_;
  if (!div) {
    div = this.div_ = document.createElement('DIV'); 
        div.id=me.marker_id;
    var panes = this.getPanes();
    panes.overlayImage.appendChild(div);
  }
  var point = this.getProjection().fromLatLngToDivPixel(this.latlng_);
  if (point) {
      div.className = 'map-marker-toekomst show-hovercard';
      div.style.left = (point.x-6) + 'px';
      div.style.top = (point.y-23) + 'px';
      $(div).attr('data-hovercard-content', me.hovercard_content);

  }
};

CustomMarkerToekomst.prototype.remove = function() {
  if (this.div_) {
    this.div_.parentNode.removeChild(this.div_);
    this.div_ = null;
  }
};

CustomMarkerToekomst.prototype.getPosition = function() {
 return this.latlng_;
};
/* ***** Eind CustomMarker Toekomst ***** */

我的 div 'map-marker-toekomst' 的 CSS 是;我已经验证了背景确实存在。:

.map-marker-toekomst {
position: absolute;
width: 21px;
height: 25px;
background: url(removed/img/mapmarker_blue.png) no-repeat;
cursor: pointer;
}

我的结果是从 php 的数据库查询填充到 javascript 中的:

   echo "            pos = new google.maps.LatLng(" . $row['latitudedecimal'] . "," .  
$row['longitudedecimal'] . ");\n";
   echo "            overlay = new CustomMarkerToekomst(pos, map, \"" . $row['marker'] 
. "\", '" . $row['luchthavennaam'] . "');\n";
   echo "            overlay.setMap(map);\n";
   echo "            bounds.extend(pos);\n";
   echo "      \n";

我在这个脚本上方有一个类似的 CustomMarker,它工作正常,这是第二个问题。

4

0 回答 0