2010-07-30 13 views
2

Google Maps API v3를 사용하는 애플리케이션을 개발 중입니다. 각면에 정확히 1000km의 정사각형 인 맞춤형 오버레이를 만들고 싶습니다 (각 오버레이는 실제로는 1x2 픽셀을 나타내는 1000x1000 투명 PNG입니다). 현재 구현 한 내용은 다음과 같습니다.Google지도에서 사용자 정의 오버레이를 투영 계정으로 변환하려면 어떻게해야합니까?

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를 적절하게 변형시킬 수 있습니까?

답변

0

정보가 충분하지 않지만 오픈 소스 proj4js 라이브러리가 유용합니다. 예를 들어 다양한 프로젝션 변환을 수행 할 수 있습니다. Google의 구형 메르카토르 투영 시스템.