diff --git a/src/views/gisMapPage/gisMapBox1.vue b/src/views/gisMapPage/gisMapBox1.vue index 49a2d4e..e21052a 100644 --- a/src/views/gisMapPage/gisMapBox1.vue +++ b/src/views/gisMapPage/gisMapBox1.vue @@ -114,6 +114,31 @@ if (feature) event.emit('map-click', Object.values(e.lngLat), feature.properties); setHighlight(feature); }); + map.on('mouseenter', 'point', e => { + Object.values(highlightLayers).forEach(layer => { + if (layer.setData) layer.setData({ type: 'FeatureCollection', features: [] }); + }); + const feature = ( + map.queryRenderedFeatures([ + [e.point.x - 10 / 2, e.point.y - 10 / 2], + [e.point.x + 10 / 2, e.point.y + 10 / 2], + ]) || [] + ).filter(i => layerIds.includes(i.layer.id))[0]; + if (feature) event.emit('map-moveOn', Object.values(e.lngLat), feature.properties); + setHighlight(feature); + }); + map.on('mouseleave', 'point', e => { + Object.values(highlightLayers).forEach(layer => { + if (layer.setData) layer.setData({ type: 'FeatureCollection', features: [] }); + }); + const feature = ( + map.queryRenderedFeatures([ + [e.point.x - 10 / 2, e.point.y - 10 / 2], + [e.point.x + 10 / 2, e.point.y + 10 / 2], + ]) || [] + ).filter(i => layerIds.includes(i.layer.id))[0]; + if (feature) event.emit('map-moveLeave', Object.values(e.lngLat), feature.properties); + }); }; const loadData = async () => { diff --git a/src/views/gisMapPage/gisMapBox1.vue b/src/views/gisMapPage/gisMapBox1.vue index 49a2d4e..e21052a 100644 --- a/src/views/gisMapPage/gisMapBox1.vue +++ b/src/views/gisMapPage/gisMapBox1.vue @@ -114,6 +114,31 @@ if (feature) event.emit('map-click', Object.values(e.lngLat), feature.properties); setHighlight(feature); }); + map.on('mouseenter', 'point', e => { + Object.values(highlightLayers).forEach(layer => { + if (layer.setData) layer.setData({ type: 'FeatureCollection', features: [] }); + }); + const feature = ( + map.queryRenderedFeatures([ + [e.point.x - 10 / 2, e.point.y - 10 / 2], + [e.point.x + 10 / 2, e.point.y + 10 / 2], + ]) || [] + ).filter(i => layerIds.includes(i.layer.id))[0]; + if (feature) event.emit('map-moveOn', Object.values(e.lngLat), feature.properties); + setHighlight(feature); + }); + map.on('mouseleave', 'point', e => { + Object.values(highlightLayers).forEach(layer => { + if (layer.setData) layer.setData({ type: 'FeatureCollection', features: [] }); + }); + const feature = ( + map.queryRenderedFeatures([ + [e.point.x - 10 / 2, e.point.y - 10 / 2], + [e.point.x + 10 / 2, e.point.y + 10 / 2], + ]) || [] + ).filter(i => layerIds.includes(i.layer.id))[0]; + if (feature) event.emit('map-moveLeave', Object.values(e.lngLat), feature.properties); + }); }; const loadData = async () => { diff --git a/src/views/sponeScreen/HaiMianScreen/index.vue b/src/views/sponeScreen/HaiMianScreen/index.vue index 39d0d18..4190fbf 100644 --- a/src/views/sponeScreen/HaiMianScreen/index.vue +++ b/src/views/sponeScreen/HaiMianScreen/index.vue @@ -3,7 +3,13 @@