私はGoogleマップとAPIを初めて使用し、クリックでマップを特定の領域にパンさせようとしています。APIリファレンスで必要なものを見つけるのに苦労しており、これについてどうすればよいかまったくわからないので、あまりありませんが、これまでのところ私が持っているものは次のとおりです.
任意の領域をクリックすると、その領域のほとんどがパンされ、ズームインして表示されるようにしたいと考えています。
ほとんどの機能は、マップ自体をクリックするのではなく、テキスト名をクリックしてマップをロードし、正しい場所を表示することで実現します。
function initialize_neighbourhoodmap(neighbourhood_name) {
var latlng = new google.maps.LatLng(42.949442,-81.228125);
var zoom = 11;
var neighbourhood_center = get_neighbourhood_center();
var myOptions = {
zoom: zoom,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("neighbourhood_map"),
myOptions);
var neighbourhoods = new google.maps.KmlLayer('http://maps.google.com/maps/ms?authuser=0&ie=UTF8&hl=en&oe=UTF8&vps=3&msa=0&output=kml&msid=217366496682144933685.0004bf3be50d3cd7ad1c2', {suppressInfoWindows: true, preserveViewport:true});
neighbourhoods.setMap(map);
google.maps.event.addListener(neighbourhoods, 'click', function(KmlFeatureData) {
var neighbourhood_name = KmlFeatureData.featureData.name;
load_neighbourhood(neighbourhood_name, neighbourhoods);
window.location = "#neighbourhood-neighbourhood "+neighbourhood_name;
});
if(typeof neighbourhood_name !== 'undefined'){
load_neighbourhood(neighbourhood_name, neighbourhood_center);
}
}
function load_neighbourhood (neighbourhood_name, neighbourhoods) {
var neighbourhoodbounds = nonexistentgetboundsfunction(neighbourhood_name);
map.panToBounds(neighbourhood_center[neighbourhood_name][0]);
$('#neighbourhood h2').html('neighbourhood '+neighbourhood_name);
}