wp-plugin-leaflet-map icon indicating copy to clipboard operation
wp-plugin-leaflet-map copied to clipboard

Customize popup text style

Open garageeks opened this issue 4 years ago • 2 comments

Hi to all, I'm trying to style the popups, which are populated by a GeoJSON features collection. While working directly with LeafletJS, in the OnEachFeature function, I can compose the popup content with html, therefore I assign CSS classes to the title, headings etc. How can I add CSS in the popup content here? I see the relevant OnEachFeature function is in class.geojson-shortcode.php, I could hack it, but perhaps there is a supported way to do this. For instance, I don't know what this does:

window.WPLeafletMapPlugin.template( popup_text, feature.properties );

Thank you for your help Nick

garageeks avatar May 27 '21 08:05 garageeks

check out window.WPLeafletMapPlugin.geojsons: that should be an array of L.GeoJSON layers which you should be able to use to run onEachFeature.

also template is the only function I've written a unit test for! https://github.com/bozdoz/wp-plugin-leaflet-map/blob/master/tests/App.test.js

It basically uses properties from your GeoJSON to create a string:

Property: {name} would create a different popup for each layer that has a name property for example.

bozdoz avatar May 27 '21 16:05 bozdoz

If this works for you, I will close this ticket

bozdoz avatar Jun 25 '21 01:06 bozdoz