2

Google Maps API v3 を使用するアプリケーションを開発しています。各辺が正確に 1000 km の正方形であるカスタム オーバーレイを作成したいと考えています (各オーバーレイは実際には 1000x1000 の透明な png であり、各ピクセルは 1 平方 km を表します)。私の現在の実装はこれです:

function PngOverlay(map,loc) {
    this._png = null;
    this._location = loc; //lat,lng of the square's center
    this.setMap(map);
}

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

PngOverlay.prototype.onAdd = function() {
    this._png = new Element('image',{ //using mootools
    'src': pngForLoc(this._location),
    'styles': {
        'width': 1000,
        'height': 1000,         
        'position': 'absolute'
    }
});

var panes = this.getPanes();
    panes.overlayLayer.appendChild(this._png);
}

PngOverlay.prototype.onRemove = function() {
    this._png.parentNode.removeChild(this._png);
    this._png = null;
}

PngOverlay.prototype.draw = function() {
    var dp = this.getProjection().fromLatLngToDivPixel(this._location);     
    var ps = this._png.getSize();

    var t = dp.y - (ps.y / 2);
    this._png.setStyle('top',t);

    var l = dp.x - (ps.x / 2);
    this._png.setStyle('left',l);
}

私の質問は次のとおりです。Google マップの投影法を説明するために、もしあるとすれば何をする必要がありますか? メルカトルについての私の限定的な理解は、水平方向の距離は保持されますが、垂直方向の距離は保持されないということです。それを考慮してpngを適切に変換するにはどうすればよいですか?

4

1 に答える 1

0

十分な情報はありませんが、オープン ソースの proj4js ライブラリが役立つことがわかるかもしれません。これは、さまざまな投影変換を実行できるためです。Google の球状メルカトル図法システムに。

于 2010-11-23T19:23:40.527 に答える