传单:如何在鼠标悬停在这个标记上时只突出显示位于标记后面的多边形?
Leaflet: How can I highlight only the polygon which lays behind a marker on mouseover this marker?
在 php 上循环,我生成了一些多边形和标记。现在我想突出显示位于鼠标悬停标记后面的一个多边形。但是下面的代码始终突出显示相同的多边形。无论将鼠标悬停在哪个标记上,它始终突出显示相同的多边形。我认为问题在于它总是采用循环的最后一个多边形。我怎样才能让鼠标悬停的标记突出显示它后面的多边形?非常感谢..
<?PHP
for ($i=0;$i<=count($station);$i++) {
?>
var polygon = new L.Polygon(line, {
color: pastel,
weight: 0.4,
opacity: 0.1,
fillColor: pastel,
fillOpacity: 0.05,
interactive: true
});
polygon.addTo(map);
var myIcon = L.divIcon({
className: 'divIcon',
iconSize: new L.Point(35, 15),
iconAnchor:[18, 20],
zIndexOffset: 1000,
html: '<?=$desc1[$i]?>'
});
var marker = L.marker([x1, y1], {icon: myIcon})
.addTo(map)
.bindTooltip('<?=$desc[$i]?>');
marker.on('mouseover', function() {
polygon.setStyle({
fillOpacity: 0.5
});
});
marker.on('mouseout', function() {
polygon.setStyle({
fillOpacity: 0.05
});
});
<?PHP
}
?>
像这样引用标记上的多边形:
var polygon = new L.Polygon(line, {
color: pastel,
weight: 0.4,
opacity: 0.1,
fillColor: pastel,
fillOpacity: 0.05,
interactive: true
});
polygon.addTo(map);
var myIcon = L.divIcon({
className: 'divIcon',
iconSize: new L.Point(35, 15),
iconAnchor:[18, 20],
zIndexOffset: 1000,
html: '<?=$desc1[$i]?>'
});
var marker = L.marker([x1, y1], {icon: myIcon})
.addTo(map)
.bindTooltip('<?=$desc[$i]?>');
marker.refPoly = polygon;
marker.on('mouseover', function(e) {
e.target.refPoly.setStyle({
fillOpacity: 0.5
});
});
marker.on('mouseout', function(e) {
e.target.refPoly.setStyle({
fillOpacity: 0.05
});
});
在 php 上循环,我生成了一些多边形和标记。现在我想突出显示位于鼠标悬停标记后面的一个多边形。但是下面的代码始终突出显示相同的多边形。无论将鼠标悬停在哪个标记上,它始终突出显示相同的多边形。我认为问题在于它总是采用循环的最后一个多边形。我怎样才能让鼠标悬停的标记突出显示它后面的多边形?非常感谢..
<?PHP
for ($i=0;$i<=count($station);$i++) {
?>
var polygon = new L.Polygon(line, {
color: pastel,
weight: 0.4,
opacity: 0.1,
fillColor: pastel,
fillOpacity: 0.05,
interactive: true
});
polygon.addTo(map);
var myIcon = L.divIcon({
className: 'divIcon',
iconSize: new L.Point(35, 15),
iconAnchor:[18, 20],
zIndexOffset: 1000,
html: '<?=$desc1[$i]?>'
});
var marker = L.marker([x1, y1], {icon: myIcon})
.addTo(map)
.bindTooltip('<?=$desc[$i]?>');
marker.on('mouseover', function() {
polygon.setStyle({
fillOpacity: 0.5
});
});
marker.on('mouseout', function() {
polygon.setStyle({
fillOpacity: 0.05
});
});
<?PHP
}
?>
像这样引用标记上的多边形:
var polygon = new L.Polygon(line, {
color: pastel,
weight: 0.4,
opacity: 0.1,
fillColor: pastel,
fillOpacity: 0.05,
interactive: true
});
polygon.addTo(map);
var myIcon = L.divIcon({
className: 'divIcon',
iconSize: new L.Point(35, 15),
iconAnchor:[18, 20],
zIndexOffset: 1000,
html: '<?=$desc1[$i]?>'
});
var marker = L.marker([x1, y1], {icon: myIcon})
.addTo(map)
.bindTooltip('<?=$desc[$i]?>');
marker.refPoly = polygon;
marker.on('mouseover', function(e) {
e.target.refPoly.setStyle({
fillOpacity: 0.5
});
});
marker.on('mouseout', function(e) {
e.target.refPoly.setStyle({
fillOpacity: 0.05
});
});