我正在使用GMaps.js在一張地圖上顯示多個疊加層(類似於AirBNB的地圖)。我很新的JavaScript和GMaps API所以我用2個下列問題有困難:Gmaps.js - 如何將「指針」添加到疊加層並使其可點擊?
我可以自定義風格的疊加,但是,當他們出現在屏幕上,他們缺少的「指示器」(又名矩形底部的小三角形位),而不是顯示爲簡單的矩形。我怎樣才能添加這些「三角形」?
我希望疊加層可點擊。我看了一下,看起來解決方案是addListener,但我見過的所有例子都只有一個標記(在這種情況下不是多個),也沒有使用GMaps.js的例子。什麼是最好的方法來做到這一點?
我的代碼如下。非常感謝!
<script>
// I've included the Gmaps API and gmaps.js here
jQuery(function($) {
map = new GMaps({
div: '#map',
lat: -23.873209,
lng: 201.155845,
zoom: 12,
});
// the Body contains multiple event_location elements which have data-lat and data-lng defined for each event by PHP, which is used below - this part is not a problem
$('.event_location').each(function() {
map.drawOverlay({
lat: $(this).attr('data-lat'),
lng: $(this).attr('data-lng'),
content: "<div class='map_overlay' style='background-color: blue;'><a href='" + $(this).attr('data-url') + "'>" + $(this).attr('data-subject') + "</a></div>"
});
});
});
</script>
http://stackoverflow.com/questions/24641958/gmap-js-mouseover-event-on-an-overlay-is-it-possible有一個很好的解決方案 – user6122500