2013-06-02 8 views
0

Google지도 위젯의 경계를 설정하려면 어떻게해야하나요? 예를 들어, [SW 코너 : 40.5, -25.5] - [NE 코너 79.5, 178.5] 사각형 만 필요합니다. 지금은 또 다른 질문에서 같은 코드를 사용하고 있습니다 :Google지도 API v3을 사용하여지도의 일부분 자르기

var strictBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(40.5, -25.5), 
    new google.maps.LatLng(79.5, 178.5) 
); 

// Listen for the dragend event 
google.maps.event.addListener(map, 'dragend', function() { 
    if (strictBounds.contains(map.getCenter())) return; 

    // We're out of bounds - Move the map back within the bounds 

    var c = map.getCenter(), 
     x = c.lng(), 
     y = c.lat(), 
     maxX = strictBounds.getNorthEast().lng(), 
     maxY = strictBounds.getNorthEast().lat(), 
     minX = strictBounds.getSouthWest().lng(), 
     minY = strictBounds.getSouthWest().lat(); 

     if (x < minX) x = minX; 
     if (x > maxX) x = maxX; 
     if (y < minY) y = minY; 
     if (y > maxY) y = maxY; 

     map.setCenter(new google.maps.LatLng(y, x)); 
    }); 

을하지만 필요한 효과를 제공하지 않습니다 - 어쨌든,이 코드는지도와 사용자가 엄격한 경계에 걸쳐 조각을보고 확대 할 수 있습니다.

그래서 전 세계지도에서 nesseasary 부분을 자르기위한 API v3의 방법이 있습니까? 나는 그냥 추가로지도를 초기화 할 때 당신은 그것을 할 수있는 해당 MINZOOM 속성

을 설정하여 범위를 축소하는 사용자를 허용하지 않을 수 있습니다 귀하의 경우 생각

+0

https://developers.google.com/maps/documentation/staticmaps/#Limits는 하루 요청 제한에 관한 것입니다. –

+0

https://groups.google.com/forum/?hl=ko&fromgroups#!search/static을 시도하십시오. $ 20maps $ 20google $ 20v3 linmits 페이지에는 줌에 대한 설명이 있습니다. –

+0

[this] (http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?lat=65.738268&lng=244.306000&zoom=3&type)과 같은 작업을 수행 할 수 있습니다. = m & filename = http : //www.geocodezip.com/geoxml3_test/so_wholeworldkmld.kml) (불투명 한 레이어로 원하는 경계 바깥의지도 타일을 덮습니다). – geocodezip

답변

0

마지막으로 나는이 문제를 geocodezip 권고대로 해결하기로 결정했습니다. 자세한 내용은 this page의 소스 코드를 참조하십시오.

1

, 또는 이미 다음과 같이 초기화 후 :

map.setOptions({minZoom:5}); 
관련 문제