Add pushpins via javascript

Jan 24, 2010 at 9:13 PM

Hi all!

Is it possible to add / remove pushpins via javascript?

If not, this would be a great functionality to add. :)

Keep up this excellent code!

Jun 2, 2010 at 5:19 PM

I am interested in this as well, I need to selectively turn off/on markers based on what the user wants to see.  Thank you :)

Apr 12, 2012 at 5:37 AM
bckspc wrote:

Hi all!

Is it possible to add / remove pushpins via javascript?

If not, this would be a great functionality to add. :)

Keep up this excellent code!

Hi, Are you got Solution to this discussion?. If yes, Please give me the details!

Jun 15, 2013 at 5:52 PM
You can add the following sentence to the GoogleMap.js below the "load" function and you'll have a marker any time that you click in the Map.
GEvent.addListener(map, "click", function (marcador, punto) {
                // Crear el nuevo marcador y mostrar sus coordenadas
                var opts = {
                    title: "New Marker by click"
                };
                var nuevoMarcador = new GMarker(punto,opts);
                GEvent.addListener(nuevoMarcador, "click", function () {
                    this.openInfoWindowHtml("Lat: " + this.getPoint().lat() + "<br/>Lon: " + this.getPoint().lng());
                });
                map.addOverlay(nuevoMarcador);
            });
The thing is that I want enable and disable this functionality depending of the Page where I'm render. Do you know how to do it? Anyone else could help me?