2011-06-14 5 views
0

MapTiler를 통해 만든 아주 작은 맞춤형지도가 있고 GMaps로 렌더링하기가 쉽지 않습니다. 필요한 몇 줄의 코드의 기본 사항은 다음과 같습니다.Google지도 V3 KML 레이어 (ImageMapType을 통해)

너무 멋진 멋진 KML 레이어가 있습니다.

그러나 .... 내 인생에서 나는 두 층을 함께 표시 할 수 없습니다. KML에 렌더링을 지시하면 맞춤지도 레이어가 사라집니다. Firebug는 심지어 내 맞춤 타일도 요청하지 않는다고 알려줍니다. 이상적으로는 맞춤지도 레이어 위에 KML 레이어가 필요합니다. 그것은 몇 가지 영국의 랜드 마크가있는 곳을 보여줄 것입니다.

내 생각에 투영 형식과 충돌을 생각하고 있지만 두 레이어를 모두 기본지도에서 개별적으로 렌더링하면 실제로 어둠 속에 있습니다.

Google지도 V3의 사용자 정의지도 유형을 통해 KML 레이어에 대한 조언을 해 줄 수 있습니까?

var MyCustomMapType = new google.maps.ImageMapType({ 
getTileUrl: function(tile, zoom) { 
     return "/static/images/maps/uk/" + zoom+"/"+tile.x+"/"+ tile.y +".png"; 
}, 
tileSize: new google.maps.Size(256, 256), 
    }); 

    function init(){ 

    var mapOpts = { 
    zoom: 6, 
    center: new google.maps.LatLng(53.94315470224928, -3.515625), 
    mapTypeId: google.maps.MapTypeId.ROADMAP 
}; 

map = new google.maps.Map(document.getElementById("map_canvas"), mapOpts); 
map.overlayMapTypes.insertAt(0, MyCustomMapType); 
var cathedrals = new google.maps.KmlLayer('http://pointing_at_my/kml/'); 

// as soon as this executes, ImageMapType layer disappears 
cathedrals.setMap(map); 
} 

답변

0

가 해결 주셔서 감사합니다. 그냥 바보가되지 마라.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
    <script type="text/javascript"> 

     var map, cathedrals; 

     var ukOverlay = new google.maps.ImageMapType({ 

      getTileUrl: function(coord, zoom) { 

       var ymax = 1 << zoom; 
       var y = ymax - coord.y -1; 
       return "/static/images/maps/uk/" + zoom+"/"+coord.x+"/"+y+".png"; 

      }, 
      tileSize: new google.maps.Size(256, 256), 
      isPng: true 

     }); 

function init(){ 

    var mapOpts = { 
     zoom: 6, 
     center: new google.maps.LatLng(54.40315470224928, -3.515625), 
     mapTypeId: google.maps.MapTypeId.HYBRID , 
     disableDefaultUI: false, 
     mapTypeControl: false, 
     scrollwheel: false, 
     navigationControl: false, 
     mapTypeControl: false, 
     scaleControl: false, 
     draggable: false 
    }; 

    map = new google.maps.Map(document.getElementById("map_canvas"), mapOpts); 
    cathedrals = new google.maps.KmlLayer('http://cathedralcafes.co.uk/kml/', {preserveViewport: true}); 
    map.overlayMapTypes.insertAt(0, ukOverlay);  
    cathedrals.setMap(map); 
} 

    </script> 
관련 문제