Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Properties #45

Open
dariospace opened this issue Jun 10, 2024 · 5 comments
Open

Custom Properties #45

dariospace opened this issue Jun 10, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request Please Test!

Comments

@dariospace
Copy link

dariospace commented Jun 10, 2024

Hey @morehawes, awesome work with Waymark Jow! It deserves more stars ⭐️. Quick questions:

  • Can this feature make a comeback and disabled with a filter instead? You removed it on 1.1.0. Removed Settings for importing custom GeoJSON properties. We are creating a Real Estate map and we need custom properties besides the default ones.
  • How should we target the callback function to get a property from a marker into an input somewhere in the page? We want to get the properties for selected markers to add them somewhere else as a table.
  • Is is possible to show a property as the marker icon instead of text/html/icon? Say we want to show a property price, or square meters.

Cheers mate!

@morehawes
Copy link
Collaborator

Hi @dariospace,

Thanks for reaching out and for your kind words 🙏

Can this feature make a comeback and disabled with a filter instead? You removed it on 1.1.0. Removed Settings for importing custom GeoJSON properties.

I have to apologise for removing this feature without warning! This was one of a number of smaller settings and features that I removed in order to try and simplify the plugin codebase. This was much needed for future plans!

we need custom properties besides the default ones

This feature stored expected custom properties by simply appending them to the Overlay Description as a HTML <table>, which isn't very helpful if you are looking to do something else with the values. It also only did this once - on import of the original GeoJSON, so this was a pretty crude implementation.

Could you provide more specifics, ideally with an example of what you are trying to achieve? Currently unexpected properties are removed, but I can see that it would be useful to provide a mechanism for storing and accessing expected properties.

How should we target the callback function to get a property from a marker into an input somewhere in the page? We want to get the properties for selected markers to add them somewhere else as a table.

Please check out this example, here the title property is accessed for each Overlay like so:

layer.feature.properties.title

I hope this helps.

Is is possible to show a property as the marker icon instead of text/html/icon? Say we want to show a property price, or square meters.

This sounds quite custom to your project, however if in the future properties are stored and available as outlined above then yes this kind of customisation would be possible.

Are you using this for a commercial project? Would you be willing to sponsor the development of such a feature?

Cheers,

Joe

@morehawes morehawes added question Further information is requested low priority labels Jun 10, 2024
@dariospace
Copy link
Author

  1. Custom Properties: we are loading a GeoJSON dynamically after an API call, the issue is that it seems you've added a sanitazing? function that removes any property that doesn't match default properties. We would need a filter to disable that sanitazing function on the GeoJSON when it is stored as a custom meta in the Map Post Type.

We import them once and we will access them later on the front end programatically, say layer.property.id or layer.property.square_meter

  1. Yes, we've tried that layer.feature.properties.title, and it worked, thanks. What we are looking is callback function when a marker is clicked instead. Marker is clicked > We store the title/id/x property

  2. It aims to be a commercial project. It is an MVP right, I might be able to break the piggy bank 🐷.

We don't want to modify the code and we couldn't find many filters to get what we need!

@morehawes
Copy link
Collaborator

Thanks for the extra detail :)

We would need a filter to disable that sanitazing function on the GeoJSON when it is stored as a custom meta in the Map Post Type.

Instead of disabling, I think a mechanism for storing and accessing expected properties is a good idea.

I will definitely think more on this.

Cheers,

Joe

@morehawes morehawes added enhancement New feature or request and removed question Further information is requested labels Jun 11, 2024
@morehawes
Copy link
Collaborator

We don't want to modify the code and we couldn't find many filters to get what we need!

Good point, looks of room for improvement here! This might be worth a new issue/discussion to gather ideas for actions/filters.

@morehawes morehawes self-assigned this Jun 13, 2024
morehawes added a commit that referenced this issue Jun 13, 2024
**Overlay Properties** - Read GeoJSON feature properties when importing (Settings > Overlays > Properties). If Waymark finds data for the specified property keys they will stored upon import. These can be automatically appended to the Overlay Description, or accessed programatically via the `layer.feature.properties` Object. Thanks to [dariospace](https://github.com/dariospace) for the [requesting](#45) the return of this feature.
@morehawes
Copy link
Collaborator

Hi @dariospace,

I have just released v1.3.0 of the plugin:

Overlay Properties - Read GeoJSON feature properties when importing (Settings > Overlays > Properties). If Waymark finds data for the specified property keys they will stored upon import. These can be automatically appended to the Overlay Description, or accessed programatically via the layer.feature.properties Object.

Once the expected properties have been imported, they can now be accessed on the front-end like so:

//Our Callback Function
const waymark_properties = (Waymark) => {
  if (typeof Waymark !== "object" || typeof jQuery !== "function") {
    console.error("Waymark or jQuery not loaded");
  }
  
  // Iterate over each Overlay
  Waymark.map_data.eachLayer(function(layer) {
    // When the layer is clicked
    layer.on('click', function(e) {
      alert(JSON.stringify(e.target.feature.properties));
    });
  });
};

Please let me know if this works as expected for you.

Cheers,

Joe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Please Test!
Development

No branches or pull requests

2 participants