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 を使用して変更を適用します。私のonclickは次の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);
}
これは元のスタイルなどを保持しません。