Вот небольшой взлом, чтобы кнопка сброса работала на v3.Я использую jQuery здесь.
var attachEventToResetButton;
// Attach event to the reset button
var attachResetEvent = function(){
var $resetImg = $('img[src*=mapcontrols3d6.png]');
// We have to check if the image is available yet.
// The reason is although the map has been loaded, the navigation might
// take some time to load and we don't know when it will be fully loaded.
// There doesn't seem to have an event for "Navigation loaded" in the API
// So here is a way to work around
if ($resetImg.length > 0)
{
$resetImg.css('cursor', 'pointer').attr('title', 'Return to center').click(function(){
alert('Clicked on reset button');
// Put your code to reset the map here. For example:
//map.setMapTypeId(MAP_TYPE_ID);
//map.setCenter(new google.maps.LatLng(LAT, LNG));
//map.setZoom(ZOOM_LEVEL);
});
window.clearInterval(attachEventToResetButton);
}
}
// Periodically checking to attach event to the reset button
attachEventToResetButton = window.setInterval(attachResetEvent, 500);
Что я сделал, я заметил, что имя файла сброса образа - mapcontrols3d6.png.Поэтому я установил интервал, чтобы проверить, загружено ли это изображение (т.е. доступно) еще.Если да, я присоединяю к нему функцию.
Поскольку это хак, у него есть проблема.Основным является то, что мы должны полагаться на имя файла сброса образа.Так что скрестите пальцы, что Google не будет обновлять это.
У кого-нибудь есть какой-нибудь лучший способ?