Javascript 标记在传单中的悬停
我想问一下,如果不点击传单地图上的标记,是否可以将鼠标悬停Javascript 标记在传单中的悬停,javascript,leaflet,Javascript,Leaflet,我想问一下,如果不点击传单地图上的标记,是否可以将鼠标悬停 var markers = [ ["<b style='font-size:15pt;'> ROXAS CITY CHAPTER </b> <br> <i style='font-size:12pt;'> JUAN DELA CRUZ </i> <br>juan@yahoo.com", 11.58528,122.75111], ["<b style='font
var markers = [
["<b style='font-size:15pt;'> ROXAS CITY CHAPTER </b> <br> <i style='font-size:12pt;'> JUAN DELA CRUZ </i> <br>juan@yahoo.com", 11.58528,122.75111],
["<b style='font-size:15pt;'> MANILA CITY CHAPTER </b> <br> <i style='font-size:12pt;'> PEDRO DELA CRUZ </i> <br>pedro@gmail.com", 14.599512,120.984222],
["<b style='font-size:15pt;'> CANADA CHAPTER </b> <br> <i style='font-size:12pt;'> SIMON DELA CRUZ </i> <br>simon@gmail.com", 53.631611 ,-113.323975]
];
for ( var i=0; i < markers.length; i++ ){
marker = L.marker ([markers[i][1], markers[i][2]], {icon: myIcon})
.bindPopup(markers[i][0])
.addTo( map );
}
这是我的密码
传单.js
var map = L.map( 'map', {
center: [20.0, 5.0],
maxZoom: 16,
minZoom: 2,
zoom: 2
})
L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
subdomains: ['a', 'b', 'c']
}).addTo( map )
var myURL = jQuery( 'script[src$="leaf-demo.js"]' ).attr( 'src' ).replace( 'leaf-demo.js', '' )
var myIcon = L.icon({
iconUrl: myURL + 'images/pin24.png',
iconRetinaUrl: myURL + 'images/pin48.png',
iconSize: [29, 24],
iconAnchor: [9, 21],
popupAnchor: [0, -14]
})
var map=L.map('map'{
中间:[20.0,5.0],
maxZoom:16,
minZoom:2,
缩放:2
})
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'{
属性:“©;”,
子域:['a','b','c']
}).addTo(地图)
var myURL=jQuery('script[src$=“leaf demo.js”]”)。attr('src')。replace('leaf demo.js',“”)
var myIcon=L.icon({
iconUrl:myURL+'images/pin24.png',
iconRetinaUrl:myURL+'images/pin48.png',
iconSize:[29,24],
iconAnchor:[9,21],
popupAnchor:[0,-14]
})
这是它在传单地图中显示标记和数据的地方
var markers = [
["<b style='font-size:15pt;'> ROXAS CITY CHAPTER </b> <br> <i style='font-size:12pt;'> JUAN DELA CRUZ </i> <br>juan@yahoo.com", 11.58528,122.75111],
["<b style='font-size:15pt;'> MANILA CITY CHAPTER </b> <br> <i style='font-size:12pt;'> PEDRO DELA CRUZ </i> <br>pedro@gmail.com", 14.599512,120.984222],
["<b style='font-size:15pt;'> CANADA CHAPTER </b> <br> <i style='font-size:12pt;'> SIMON DELA CRUZ </i> <br>simon@gmail.com", 53.631611 ,-113.323975]
];
for ( var i=0; i < markers.length; i++ ){
marker = L.marker ([markers[i][1], markers[i][2]], {icon: myIcon})
.bindPopup(markers[i][0])
.addTo( map );
}
var标记=[
[“罗克萨斯市章
胡安·德拉·克鲁兹
juan@yahoo.com", 11.58528,122.75111],
[“马尼拉市章
佩德罗·德拉·克鲁斯
pedro@gmail.com", 14.599512,120.984222],
[“加拿大分会
西蒙·德拉·克鲁兹
simon@gmail.com", 53.631611 ,-113.323975]
];
对于(var i=0;i
以下是一张图片,以供更多了解
您可以在上使用title属性 另一种方法是使用鼠标悬停事件触发openPopup:
map.on('mouseover',function(ev) {
ev.layer.openPopup()
})
在标记器上的添加
mouseover
事件上讨论了该问题,并在处理程序中调用openPopup()
,如下所示:
marker = L.marker(...);
marker.on('mouseover',function(ev) {
ev.target.openPopup();
});
或
我已经为相同的设置了JSFIDLE:可以通过
marker.on('mouseover',function() {
marker.openPopup();
});
通过L.marker创建标记的位置。该标记是否悬停?
marker.on('mouseover',function() {
marker.openPopup();
});