Googleマップの衛星バージョンを表示するコードがありますが、変更すると
map.setMapType(G_HYBRID_MAP);
G_TERRAIN_MAPに、最初のマップが地形に変わります。アドレスを選択しても、アドレスが読み込まれません。そして私が変わるとき
mapControl.addRelationship(G_SATELLITE_MAP、G_HYBRID_MAP、 "ラベル"、false);
マップが機能しなくなります。
私は、Googleマップにポイントする場所への座標を与えるリンクでonClick = "findLocation"を使用しており、その場所にもズームインします。地形図を使いたい
完全なJavascript
// -- Location API -- //
var map;
var geocoder;
function initialize() {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(34 , 0), 2);
map.getCenter();
map.setMapType(G_HYBRID_MAP);
geocoder = new GClientGeocoder();
map.addControl(new GLargeMapControl());
var mapControl = new GMapTypeControl();
//map.addControl(mapControl);
var blueIcon = new GIcon(G_DEFAULT_ICON);
blueIcon.image = "http://stlab.co.uk/sg/assets/img/mapicon.png";
blueIcon.iconSize = new GSize(133, 43);
// Set up our GMarkerOptions object
markerOptions = { icon:blueIcon };
}
var mapControl = new GHierarchicalMapTypeControl();
// Set up map type menu relationships
mapControl.clearRelationships();
mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", false);
// addAddressToMap() is called when the geocoder returns an
// answer. It adds a marker to the map with an open info window
// showing the nicely formatted version of the address and the country code.
function addAddressToMap(response) {
map.clearOverlays();
if (!response || response.Status.code != 200) {
alert("Sorry, we were unable to geocode that address");
} else {
place = response.Placemark[0];
point = new GLatLng(place.Point.coordinates[1],
place.Point.coordinates[0]);
marker = new GMarker(point, markerOptions);
map.addOverlay(marker);
map.setCenter(point, 15);
}
}
// showLocation() is called when you click on the Search button
// in the form. It geocodes the address entered into the form
// and adds a marker to the map at that location.
function showLocation() {
var address = document.forms[0].q.value;
geocoder.getLocations(address, addAddressToMap);
}
// findLocation() is used to enter the sample addresses into the form.
function findLocation(address) {
document.forms[0].q.value = address;
showLocation();
}