How Can I add Latitude, Longitude dynamically in Javascript?

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

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

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.