百度地图自定义覆盖物

// 复杂的自定义覆盖物
function ComplexCustomOverlay(point, text) {
    this._point = point;
    this._text = text;
}
ComplexCustomOverlay.prototype = new BMap.Overlay();
ComplexCustomOverlay.prototype.initialize = function(map) {
    this._map = map;
    var div = this._div = document.createElement("div");
    div.style.position = "absolute";
    div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat);
    $(div).append(this._text);
    map.getPanes().labelPane.appendChild(div);
}
ComplexCustomOverlay.prototype.draw = function() {
    var map = this._map;
    var pixel = map.pointToOverlayPixel(this._point);
    this._div.style.left = pixel.x - 100 + "px";
    this._div.style.top = pixel.y - 100 + "px";
}

你可能感兴趣的:(百度地图)