publiclab / leaflet-blurred-location-display

A library to display points which have been "blurred" for privacy with leaflet-blurred-location
https://publiclab.github.io/leaflet-blurred-location-display/examples/index.html
GNU General Public License v3.0
11 stars 12 forks source link

Use a custom function to specify popupDisplay #96

Closed nstjean closed 4 years ago

nstjean commented 4 years ago

I have pulled out the popup data into a function that can be passed in to LBLD just as JSONparser is passed in. This lets users create whatever output they want for their API data without affecting LBLD.

This is what the default function looks like:

FireShot Capture 318 - Index Leaflet BlurredLocationDisplay -

This is how a custom display can look like:

      function popupDisplay(obj) {
        var popup_content = "";
        // if (image_url) popup_content += "<img src='" + options.host + image_url + "' class='popup-thumb' />"; // not available in the api yet
        popup_content += "<h5><a href='https://publiclab.org" + obj.url + "'>@" + obj.title + "</a></h5>";
        popup_content += "<div>Joined " + obj.created_at + "</div>";
        return popup_content
      }

FireShot Capture 316 - Index Leaflet BlurredLocationDisplay -

I will be using this in LEL for the PLpeople layer.

nstjean commented 4 years ago

@sagarpreet-chadha can you check this out?

jywarren commented 4 years ago

Amazing! 🎉

nstjean commented 4 years ago

@jywarren Thanks!! Can you publish on npm?

sagarpreet-chadha commented 4 years ago

Awesome 🎉 , i do not have access for LBL npm registry.

jywarren commented 4 years ago

Sorry, yes, will publish now!

jywarren commented 4 years ago

Done v1.2.0!!