4
Google지도에서 마커를 추가하려고합니다. Google지도에 마커를 추가하려고 시도했지만이를 제거하려고했지만 지금은 아래 코드로 추가 및 제거를 모두 마쳤습니다.Google지도에서 단일 마커를 제거하는 방법
나는 그것의 저장이 예상보다 한 마커 그래서 그 값이 작아야합니다 제거한 등 때문에 내가 markers.push (마커)의 값을 설정하는 방법을<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>MapsApi</title>
<style>
#map_canvas {
width: 100%;
height: 500px;
background-color: #CCC;
}
#menu_bar{
width: 100%;
height: 150px;
position:absolute;
bottom:0px;
background-color: #CCC;
border-top:1px solid red;
}
body{
padding:0px;
margin:0px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
var markers = [];
function initialize() {
var myLatlng = new google.maps.LatLng(44.5403, -78.5463);
var mapOptions = {
zoom: 4,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
google.maps.event.addListener(map, 'click', function(event) {
addMarker(event.latLng);
});
// add marker to positon
function addMarker(location) {
var marker = new google.maps.Marker({
position: location,
map: map
});
google.maps.event.addListener(marker, 'click', function(event) {
this.setMap(null);
});
markers.push(marker);
}
// Sets the map on all markers in the array.
function setAllMap(map) {
for (var i = 0; i < markers.length; i++) {
markers[i].setMap(map);
}
}
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas"></div>
<div id="menu_bar">
</div>
</body>
</html>
그러나 여기에서 지금 문제가 .. 할 수있는 한 도움
http://stackoverflow.com/questions/18483726/how-to-remove- 단일 마커 -google-maps-api-v3/31406733 # 31406733 –