更新时间:2022-04-17 22:01:28
您可以在Geocode函数的开头添加一小段代码,该代码将在设置新标记之前删除先前的标记.试试这个:
You can add a small bit of code to the beginning of your Geocode function that will remove the previous marker before setting a new one. Try this:
function geocode(address){
if (marker) {
marker.setMap(null);
}
geocoder.geocode({ 'address': (address ? address : "Miami Beach, Florida")}, function (results, status) {