使用多个自定义标记Google地图时出现问题

时间:2013-09-14 00:52:05

标签: javascript google-maps

我遇到第二个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,工作正常,这是第二个问题。

0 个答案:

没有答案