Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is my code to add draggable markers:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Remove an overlay&lt;/title&gt; &lt;link href="css/style.css" rel="stylesheet"&gt; &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt; &lt;script&gt; var map; var markers = []; var marker, infowindow; function initialize() { var haightAshbury = new google.maps.LatLng(37.7699298, -122.4469157); var mapOptions = { zoom: 12, center: haightAshbury, mapTypeId: google.maps.MapTypeId.TERRAIN }; map = new google.maps.Map(document.getElementById('map'), mapOptions); google.maps.event.addListener(map, 'click', function (event) { addMarker(event.latLng); }); } // Add a marker to the map and push to the array. function addMarker(location) { var temp if (marker!=null) { temp=marker marker=null; } marker = new google.maps.Marker({ position: location, map: map, draggable: true }); google.maps.event.addListener(marker, 'click', markerListener); function markerListener() { alert(this.getPosition()); // this.setIcon(... } markers.push(marker); } // Sets the map on all markers in the array. function setAllMap(map) { for (var i = 0; i &lt; markers.length; i++) { markers[i].setMap(map); } } // Removes the overlays from the map, but keeps them in the array. function clearOverlays() { setAllMap(null); } // Shows any overlays currently in the array. function showOverlays() { setAllMap(map); } // Deletes all markers in the array by removing references to them. function deleteOverlays() { clearOverlays(); markers = []; } google.maps.event.addDomListener(window, 'load', initialize); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="panel"&gt; &lt;input onclick="clearOverlays();" type=button value="Hide Overlays"&gt; &lt;input onclick="showOverlays();" type=button value="Show All Overlays"&gt; &lt;input onclick="deleteOverlays();" type=button value="Delete Overlays"&gt; &lt;/div&gt; &lt;div id="map"&gt;&lt;/div&gt; &lt;p&gt;Click on the map to add markers.&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The css/style.css file:</p> <pre><code>html, body { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: medium; } #map { width: 1000px; height: 750px; border: 1px solid black; } </code></pre> <p>It is extremely tough for me to judge the problem by going through your code.But you can take the above code as model and form your code accordingly. Pls note that it uses google maps api version 3.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload