Skip to content

Commit

Permalink
feat: can zoom in cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
dadiorchen committed Apr 4, 2021
1 parent 6b4a911 commit bb62de6
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/models/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,7 @@ export default class Map{
this.layerUtfGrid.on('click', (e) => {
log.debug("click:", e);
if (e.data) {
const [lon, lat] = JSON.parse(e.data.latlon).coordinates;
if(e.data.zoom_to){
log.info("found zoom to:", e.data.zoom_to);
const [lon, lat] = JSON.parse(e.data.zoom_to).coordinates;
//NOTE do cluster click
this.map.flyTo([lat, lon], this.map.getZoom() + 2);
}else{
this.map.flyTo([lat, lon], this.map.getZoom() + 2);
}
this.clickMarker(e.data);
}
});

Expand All @@ -88,9 +80,10 @@ export default class Map{
// id: e.data.id
// };
});

this.layerUtfGrid.on('mouseout', (e) => {
log.debug("e:", e);
this.map.removeLayer(this.layerHighlight);
this.unHighlightMarker();
});
this.layerUtfGrid.addTo(this.map);

Expand Down Expand Up @@ -120,4 +113,21 @@ export default class Map{
this.layerHighlight.addTo(this.map);
}

unHighlightMarker(){
this.map.removeLayer(this.layerHighlight);
}

clickMarker(data){
this.unHighlightMarker();
const [lon, lat] = JSON.parse(data.latlon).coordinates;
if(data.zoom_to){
log.info("found zoom to:", data.zoom_to);
const [lon, lat] = JSON.parse(data.zoom_to).coordinates;
//NOTE do cluster click
this.map.flyTo([lat, lon], this.map.getZoom() + 2);
}else{
this.map.flyTo([lat, lon], this.map.getZoom() + 2);
}
}

}

0 comments on commit bb62de6

Please sign in to comment.