我正在使用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