Question

Let say i wanna make a new place in my app (based-on google map API v3). Whenever click on "add new place" button, a marker appears in my current location on the map. And when I click on the marker or drag it to somewhere that I wanna put my place, an infowindow bound with this marker appears so that i can input data.

But each time I click or drag my marker, all my text I've input into my infowindow before was lost. Someone can tell me the way to prevent data loss when drag or click on marker many times?

Here is my code to listen for clicking or dragend

 google.maps.event.addListener(marker, 'click', function() {
                        infowindow.open(map, marker);
                    });

 google.maps.event.addListener(marker, 'dragend', function() {
                        infowindow.open(map, marker);
                    });

Thanks

p/s: my English isnt very good

Was it helpful?

Solution

In your maker click function you should check if the infowindow is already open and if it is then don't open it again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top