Add marker to map when button is clicked?
-
I have been trying to figure this out for weeks but i am really stuck. I am trying to add a marker to a google map only when the user clicks the add marker button calling the addMarker function. The problem that i am having is that i cant figure out how to get this to work without passing the addMarker function into the show map function because if i do that the marker shows automatically. my showMap function is : function showMap(coords) { var googleCoords = new google.maps.LatLng(coords.latitude, coords.longitude); var mapOptions = { zoom: 14, center: googleCoords, mapTypeId: google.maps.MapTypeId.ROADMAP } var mapDiv = document.getElementById("map"); map = new google.maps.Map(mapDiv, mapOptions); } and my addMarker function is : function addMarker(map, googleCoords) { var markerOptions = { position: googleCoords, map: map, title: "marker 1", content: = "Latitude: " + coords.latitude + ", Longitude: " + coords.longitude;, clickable: true } var marker = new google.maps.Marker(markerOptions); var infoWindowOptions = { content: content, position: googleCoords } var infoWindow = new google.maps.InfoWindow(infoWindowOptions… google.maps.event.addListener(marker, "click", function() { infoWindow.open(map) })); to be clear i only want the marker to show up on the map if the user clicks the show map button...any help would be greatly appreciated.
-
Answer:
I would say that.... there is no way to make that since there is no such command available.... Good luck!
candyeye... at Yahoo! Answers Visit the source
Related Q & A:
- How to add Multiple overlays to Map?Best solution by Stack Overflow
- How to add an image to a button?Best solution by Stack Overflow
- How to change color of radio button when checked radio button?Best solution by Stack Overflow
- How To Sort a GridView Column When a Header Is Clicked?Best solution by Stack Overflow
- How can I auto fresh when a button is clicked?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.