Google マップを新しいプロジェクトに実装していますが、1 つのページでカナダの大きな (100% * 100%) マップが返されるはずです。また、ジオコーディングを使用して、マップに渡す緯度を決定しています。
コードは次のとおりです。
var myLatlng = new google.maps.LatLng(37.775, -122.4183333);
var myOptions ={
zoom: 5,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var address = "Canada";
var geocoder = new google.maps.Geocoder(address);
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
//map.setCenter(results[0].geometry.location);
//The above was too far north
map.fitBounds(results[0].geometry.viewport);
map.setZoom(5);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
「左に少し遠すぎる」ことを除けば、うまく機能しています。本質的に、それはほとんどの沿海州を遮断しています。例を次に示します。
http://50.28.69.176/~sequoia/locations.php
国がビューポートの中心にくるように、これを巧みに処理する方法を知っている人はいますか?
助けてくれてありがとう。