3
我遇到了一個問題,如何設置不同國家的縮放級別,我設法讓地圖工作和顯示國家,似乎無法解決如何設置縮放級別。谷歌地圖縮放級別爲國家
任何幫助,將不勝感激。
感謝
喬治
<script type="text/javascript">
var infowindow = null;
$(document).ready(function() { initialize(); });
function initialize() {
//var geocoder = new google.maps.Geocoder();
//geocoder.geocode({ 'address': address }, function (results, status) {
// if (status == google.maps.GeocoderStatus.OK) {
// map.setCenter(results[0].geometry.location);
// map.fitBounds(results[0].geometry.viewport);
// }
//});
var centerMap = new google.maps.LatLng(@Html.Raw(@item.strLatLong));
var myOptions = {
zoom: 4, //<<-------How can I chnage this
center: centerMap,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("WeatherMapLocation"), myOptions);
setMarkers(map, sites);
infowindow = new google.maps.InfoWindow({
content: "loading..."
});
var bikeLayer = new google.maps.BicyclingLayer();
bikeLayer.setMap(map);
}
function setMarkers(map, markers) {
for (var i = 0; i < markers.length; i++) {
var sites = markers[i];
var siteLatLng = new google.maps.LatLng(sites[1], sites[2]);
var marker = new google.maps.Marker({
position: siteLatLng,
map: map,
title: sites[0],
zIndex: sites[3],
html: sites[4]
});
var contentString = "Some content";
google.maps.event.addListener(marker, "click", function() {
infowindow.setContent(this.html);
infowindow.open(map, this);
});
}
}
</script>
我不明白你的問題。你想要像'map.setZoom(5)'這樣的東西嗎?或者根據國家設置不同的縮放比例? – mddw 2013-02-14 13:08:31
[center on a country by google maps api v3]可能重複(http://stackoverflow.com/questions/4408397/center-on-a-country-by-name-google-maps-api-v3) – geocodezip 2013-02-14 14:14:48