2015-02-06 13 views
0

geoxml3을 사용하여로드하고 스타일을 지정했습니다. 이제 중심점과 줌 레벨 만 변경하는지도를 업데이트하고 싶습니다. 내가 어떻게 이럴 수 있지.geoxml3 업데이트 센터 지점

var latlng = new google.maps.LatLng(29.722601, -11.681680); 
    var myOptions = { 
      zoom : 1, 
      //minZoom:2, 
      maxZoom:10, 
      center : latlng, 
      //disableDefaultUI: true, 
      streetViewControl: false, 
      mapTypeControl: false, 
      panControl: true, 
      zoomControl: true, 
      suppressInfoWindows : true, 
      preserveViewport : true, 
      scrollwheel: false, 
      styles:style 
     }; 

    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

    var geoXml = new geoXML3.parser({ 
     map: map, 
     singleInfoWindow: false, 
     afterParse: useTheData, 
     suppressInfoWindows : true, 
     zoom : false 
    }); 
    geoXml.parse(url_kml+'basins.kml'); 

위의 내용이로드되면 onclick을 사용하여 chnages를 적용하려고합니다. 내 온 클릭은 js 기능

function updatekmmap(region){ 
    console.log(region); 
    console.log(map); 
    var latlng = new google.maps.LatLng(29.722601, -11.681680); 
    // 
    switch(region){ 
    case "north": 
     latlng = new google.maps.LatLng(56.065192, -104.814452); 
     break; 
    } 
    gMap = new google.maps.Map(document.getElementById('map_canvas')); 
    gMap.setZoom(10);  // This will trigger a zoom_changed on the map 
    gMap.setCenter(latlng); 

} 

다음 실행이 원래 스타일 등

+0

왜지도 개체를 다시 만드시겠습니까? – MrUpsidown

+0

메신저에서'geoXml'에 줌과 중앙 위치를 설정하려고합니다. 나는 그것을하는 방법을 모른다. – shorif2000

답변

0

내가 지금 작업이 유지되지 않습니다. 나는지도 객체를 다시 만들고 있었다.

function updatekmmap(region){ 
    console.log(region); 
    console.log(map); 
    var latlng = new google.maps.LatLng(29.722601, -11.681680); 
    // 
    switch(region){ 
     case "north": 
      latlng = new google.maps.LatLng(31.137854, -90.256931); 
      break; 
     case "south": 
      latlng = new google.maps.LatLng(31.137854, -90.256931); 
      break; 
     case "caribbean": 
      latlng = new google.maps.LatLng(31.137854, -90.256931); 
      break; 
     case "eu": 
      latlng = new google.maps.LatLng(50.352658, -9.316490); 
      break; 
     case "med": 
      latlng = new google.maps.LatLng(37.309248, 18.786537); 
      break; 
     case "africa": 
      latlng = new google.maps.LatLng(-14.933886, -59.495213); 
      break; 
     case "asia": 
      latlng = new google.maps.LatLng(31.137854, -90.256931); 
      break; 
    } 
    //gMap = new google.maps.Map(document.getElementById('map_canvas')); 
    map.setZoom(3);  // This will trigger a zoom_changed on the map 
    map.setCenter(latlng); 
    //console.log(geoXml.getDefaultBounds()); 
    //return false; 
}