Skip to content

Commit

Permalink
feat: can zoom in by click cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
dadiorchen committed Apr 3, 2021
1 parent 120d4fb commit ee1fb2c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ var initialize = function() {
console.log("e:", e);
if (e.data) {
console.log('click', e.data);
const [lon, lat] = JSON.parse(e.data.latlon).coordinates;
// map.panTo(e.latlng);
// map.setView(e.latlng, map.getZoom() + 2);
// points.forEach(function(point, i) {
Expand All @@ -1013,6 +1014,10 @@ var initialize = function() {
// });
// });
//expect(e.data).property("id").a("number");

//NOTE do cluster click
map.setView([lat, lon], map.getZoom() + 2);
return;

//load points from utf cache
//TODO this might not be the best way to load the points
Expand Down Expand Up @@ -1047,7 +1052,7 @@ var initialize = function() {

//set the selected marker
const markerSelected = new window.L.marker(
[e.data.lat, e.data.lon],
[lat, lon],
{
icon: new window.L.DivIcon({
className: "greenstand-point-selected",
Expand Down Expand Up @@ -1077,17 +1082,14 @@ var initialize = function() {
console.warn("utf:", utfGridLayer);
utfGridLayer.on('mouseover', function (e) {
console.log("e:", e);
expect(e.data).match({
lat: expect.any(Number),
lon: expect.any(Number),
});
const [lon, lat] = JSON.parse(e.data.latlon).coordinates;
markerHighlight = new window.L.marker(
[e.data.lat, e.data.lon],
[lat, lon],
{
icon: new window.L.DivIcon({
className: "greenstand-point-highlight",
className: "greenstand-cluster-highlight",
html: `
<div class="greenstand-point-highlight-box" >
<div class="greenstand-cluster-highlight-box" >
<div></div>
</div>
`,
Expand All @@ -1102,10 +1104,6 @@ var initialize = function() {
});
utfGridLayer.on('mouseout', function (e) {
console.log("e:", e);
expect(e.data).match({
lat: expect.any(Number),
lon: expect.any(Number),
});
map.removeLayer(markerHighlight);
});

Expand Down

0 comments on commit ee1fb2c

Please sign in to comment.