问题
Is there an easy way to style the Zoom control in Google Maps JavaScript API v3? All what I want is just to change the standard image (http://maps.gstatic.com/intl/en_ALL/mapfiles/mapcontrols3d6.png) to my one without implementing of a custom control. I tried to change it in DOM with JQuery but I cannot find the right place to do this. Any tips would be appreciated
回答1:
So we came up with a solution to do the following on the tilesloaded event of Map:
var styleZoomControl = function ()
{
var imgs = mapCanvas.find('img[src$="mapfiles/mapcontrols3d6.png"]');
if (imgs.length > 0 || mapCanvas.find('img[src$="mapfiles/szc3d.png"]').length > 0)
{
if (imgs.length > 0)
imgs.attr('src', '/design/consumer/images/zoom-control.png');
} else
{
setTimeout(styleZoomControl, 200);
}
}
来源:https://stackoverflow.com/questions/5043419/styling-standard-zoom-control-in-google-maps-v3