我怎樣才能設置文本,當我點擊從谷歌地圖圖標標記?谷歌地圖API文本onclick文本
的要求是:當我在一個圖標,點擊文本應顯示和我在其他點擊圖標只有被選中的圖標應該有文字
這裏是我的代碼:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Marker Clustering</title>
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 7,
center: {lat: 45.9356343, lng: 25.9017273}
});
var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
icon: "/resources/service-points.png",
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
}
var locations = [
{lat: 44.426049, lng: 26.047637},
{lat: 44.428430, lng: 26.140104},
{lat: 44.487002, lng: 26.078824},
{lat: 44.431288, lng: 26.110165}
]
</script>
<script
src="https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js">
</script>
</body>
</html>
如何集成這些代碼到我的位置嗎? – razvai
標記的代碼與您擁有的代碼相同(只添加了標題,但可以刪除)..所以代碼應該放在回答標記和監聽器之前的內容strng和inforwindow之前。 – scaisEdge