views:

233

answers:

5

I would like to know how and if I can add standard HTML elements (div, button) to a specific set of coordinates on the map ?

For example I have a set of coordinates and I would like to attach a custom balloon notification to them

Google Maps with custom styled element attached to a set of coordinates

and when I pan away from the coordinates the element should disappear and when I pan back to them, the element should reappear.

Is it possible to do this with Google Maps ?

+2  A: 

you can use custom overlays - http://code.google.com/intl/de-DE/apis/maps/documentation/overlays.html#Custom_Overlays for that

roman
This is exactly what I was looking for ! Thank you very much !
Christian Toma
+2  A: 

As roman said, you can create a custom javascript object which implements GOverlay.

Here's an example from another S.O. question where the guy wanted to insert an SVG on top of a google map. However I am pretty sure you could use his solution to just insert HTML.

http://stackoverflow.com/questions/1055367/overlay-svg-diagrams-on-google-maps#answer-1083207

jessegavin
Thank you very much !
Christian Toma
A: 

What you want to look at is the openInfoWindowHtml function. You will need to add a marker to the map first. Check out this example on Google for a good example of this, combined with the nifty maximize function.

Sean Vieira
What I need is to add a plain HTML element to some coordinates on the map, not inside a Google Maps native notification window. Thank you !
Christian Toma
+1  A: 

If you want make a custom balloon, see this question:

Google Maps Bubble Templates

Chris B
I don't want to display only notification windows (bubbles). Thank you !
Christian Toma
A: 

See this as a base class for the latest Google Maps API version (v3):

Usage:

var rectBounds = new google.maps.LatLngBounds(
    new google.maps.LatLng(54.478490, 18.550357),
    new google.maps.LatLng(54.478434, 18.551952)
);
var obj = new overlayText(rectBounds, 'Some<br />HTML', objGMap3);
Nux