/ / ऑनक्लिक के बाद geocode मार्कर को हटा रहा है - जावास्क्रिप्ट, फ़ंक्शन, google-maps, google-maps-api-3, geocoding

ऑनक्लिक के बाद जियोकोड मार्कर को हटा रहा है - जावास्क्रिप्ट, फ़ंक्शन, google-maps, google-maps-api-3, geocoding

मैं गूगल मैप्स- दिशानिर्देश और जियोकोडिंग का उपयोग कर रहा हूं। पेज लोड होने पर जियोकोड एक मार्कर रखता है। क्या उपयोगकर्ता द्वारा सबमिट बटन पर क्लिक करने पर यह मार्कर हटा दिया जा सकता है? मैंने पहले पूछा और किसी ने इसका सुझाव दिया:

marker.setMap (शून्य);

लेकिन मुझे यकीन नहीं है कि उस कोड को कहां रखा जाए

यहां कोड है:

var address = document.getElementById("address").textContent.replace(/n/g, " ");
geocoder.geocode( { "address": address},
function(results, status)
{
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
}
else
{
alert("Geocode was not successful for the following reason: " + status);
}
});




var from = document.getElementById("from").value;
var to = document.getElementById("to").value;
var request = {
origin: from,
destination: to,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
document.getElementById("map").style.width = "70%";
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});

अग्रिम में धन्यवाद

उत्तर:

उत्तर № 1 के लिए 1

सबमिट बटन कहां है?

<input type="Submit" value="Submit" onclick="marker.setMap(null);" />

यह माना जा रहा है marker.setMap(null); काम करता है, ज़ाहिर है।