Skip to content

feat: Show neighbouring properties as points on map#429

Merged
cdccollins merged 1 commit intomainfrom
feat-show-neighbour-markers
Jan 25, 2024
Merged

feat: Show neighbouring properties as points on map#429
cdccollins merged 1 commit intomainfrom
feat-show-neighbour-markers

Conversation

@cdccollins
Copy link
Copy Markdown

Creates a property showNeighbourMark which when switched on creates a marker for each point passed in on the geojsonData property.

This will be useful in BOPS as it can be difficult to know when drawing a polygon whether you have selected the neighbouring properties. BOPS will pass the coordinates of the neighbours via the geojsonData prop.

@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 24, 2024

Deploy Preview for oslmap ready!

Name Link
🔨 Latest commit e74e9b3
🔍 Latest deploy log https://app.netlify.com/sites/oslmap/deploys/65b237bcc15b8f00078652fa
😎 Deploy Preview https://deploy-preview-429--oslmap.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@cdccollins cdccollins force-pushed the feat-show-neighbour-markers branch 2 times, most recently from feb6642 to dc63bea Compare January 24, 2024 15:37
Copy link
Copy Markdown
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this new feature !! 🎉

Only one small question while reviewing: when I pass geojsonData and turn on showNeighbourMarkers it's not actually displaying the default black cirlces or any other image (it does correctly re-center the map over where the points should be)? I can still see the defualt marker image fine when just displaying the singular showMarker.

Is it the same for you / is there something different about my example data than what you plan to pass in?

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          -0.13708768238623747,
          51.51141463106259
        ],
        "type": "Point"
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          -0.1359069395277004,
          51.512461774011285
        ],
        "type": "Point"
      }
    },
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "coordinates": [
          -0.1378256466718426,
          51.51303126270315
        ],
        "type": "Point"
      }
    }
  ]
}

Comment thread src/components/my-map/index.ts Outdated
featureBuffer = 40;

@property({ type: Boolean })
showNeighbourMarkers = false;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: since this prop reads from geojsonData, maybe naming as showGeojsonDataMarkers would offer more clarity on when to use it? The component itself doesn't necessarily need to know about the concept/use-case of "neighbours" I think / it works for any collection of dispersed points!

(showMarkershowCentreMarker might be nice clarification for existing prop too now that we're doubling down on this feature - but not sure it's worth a breaking change! Your call, easy enough for us to adjust our map instances on next upgrade if updated 🙂)

Comment thread src/components/my-map/index.ts Outdated
}

if (this.showNeighbourMarkers) {
this.geojsonData.features.forEach((feature: any) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rather than any this should be able to use type GeoJSONFeature from "ol/format/GeoJSON"

@cdccollins
Copy link
Copy Markdown
Author

cdccollins commented Jan 25, 2024

{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
-0.13708768238623747,
51.51141463106259
],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
-0.1359069395277004,
51.512461774011285
],
"type": "Point"
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"coordinates": [
-0.1378256466718426,
51.51303126270315
],
"type": "Point"
}
}
]
}

Thanks for looking! I think this comes down to my not knowing about geojson stuff... Do you normally pass latitude then longitude, or longitude then latitude? I've assumed that latitude is always first

EDIT - ah I see. I've somehow got it backwards somewhere. Will look into

@cdccollins cdccollins force-pushed the feat-show-neighbour-markers branch 2 times, most recently from 1bb5a92 to 693bb73 Compare January 25, 2024 10:23
Copy link
Copy Markdown
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha no worries - you're right it's just an ordering thing - if I switch locally to this then I see markers ✅

showNewMarker(
  feature.geometry.coordinates[0],
  feature.geometry.coordinates[1],
);

Lat lon ⚔️ lon lat is a whole thing in gis mapping land, it's definitely not just you!! https://observablehq.com/@clhenrick/lat-lon-or-lon-lat

Comment thread src/components/my-map/index.ts Outdated
type: "Point",
},
},
],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops let's keep default features [] here please !

Comment thread src/components/my-map/index.ts Outdated

if (this.showGeojsonDataMarkers) {
this.geojsonData.features.forEach((feature: GeoJSONFeatureCollection) => {
console.log(feature.geometry.coordinates);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry two more minor things:

  • please remove console.log()
  • I think geojsonData is the type GeoJSONFeatureCollection but the singular iterator feauture is just GeoJSONFeature !

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry 🤦‍♀️

Creates a property showNeighbourMark which when switched on creates
a marker for each point passed in on the geojsonData property.

This will be useful in BOPS as it can be difficult to know when drawing
a polygon whether you have selected the neighbouring properties. BOPS
will pass the coordinates of the neighbours via the geojsonData prop.
@cdccollins cdccollins force-pushed the feat-show-neighbour-markers branch from 693bb73 to e74e9b3 Compare January 25, 2024 10:28
Copy link
Copy Markdown
Member

@jessicamcinchak jessicamcinchak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working now & good to go by me - thanks again 🙌

Please squash & merge this whenever you're ready & I'll queue up a new release this afternoon and ping you once published to NPM 🙂

@cdccollins
Copy link
Copy Markdown
Author

Working now & good to go by me - thanks again 🙌

Please squash & merge this whenever you're ready & I'll queue up a new release this afternoon and ping you once published to NPM 🙂

Thanks so much for you help with this!

@cdccollins cdccollins merged commit ca25280 into main Jan 25, 2024
@cdccollins cdccollins deleted the feat-show-neighbour-markers branch January 25, 2024 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants