Reputation: 7416
I'm using Google Maps API V3
and the DrawingManager
.
When the mouse hovers my DrawingManager
, the title
attribute of the icons appears, but I'd like to change this title ("Dessiner une forme" here in French version) and put my own.
I try to use :
$("div.gmnoprint img[src$='drawing.png']").last().attr("title", "My custom title");
And this works, but :
drawingmanager_complete
to run this code only when the manager is fully loaded, but according to the documentation , it doesn't exist...Is there any clean and reliable way to accomplish this ?
Thank you
Upvotes: 0
Views: 389
Reputation: 4037
Unfortunately, the API or the Library does not provide any end points that can be edited by the developer's to create there own custom once. The best way to do this is to just omit the pre-existing controls and then build your own.
One way to do this is by using this approach:
$(map.getDiv()).one('mouseover','img[src="https://maps.gstatic.com/mapfiles/drawing.png"]',function(e){
$(e.delegateTarget).find('img[src="https://maps.gstatic.com/mapfiles/drawing.png"]').each(function(){
$(this).closest('div[title]').attr('title',function(){
switch(this.title){
case 'Add a marker':
return 'Add New Location';
break;
case 'Draw a circle':
return 'Draw an area';
break;
default:return this.title;
}
});
});
});
And this will work with English as a language. To achieve it regardless of the language you'll have to check the top-property of the button-image(this seems to be the only detail that may be used to determine the type of shape the button is used for).
Upvotes: 1