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