1

I have a geojson file "test.geojson" which contains image metadata for multiple images, including image url (as browseUrl) and image bounds (as imageBounds).

What I want to do is to display a corresponding image on my leaflet map by clicking on it's shape using ImageOverlay. Here is my code:

$.getJSON("test.geojson", function (geojson) {
    var geojsonLayer = new L.GeoJSON(geojson, {
        onEachFeature: function (feature, layer) {
            layer.on('click', function (feature) {
                L.imageOverlay(feature.properties.browseurl, feature.properties.imageBounds).addTo(map)
            })
        }
    }).addTo(map);
});

Unfortunatelly I get Uncaught TypeError: Cannot read property 'browseurl' of undefined when I click on a feature.

2
  • Which version are you using?
    – whyzar
    Oct 17, 2017 at 14:38
  • @whyzar Leaflet 1.2.0
    – Basile
    Oct 17, 2017 at 14:40

1 Answer 1

1

This appears to have been a bug at some point, unsure if resolved Uncaught TypeError: Cannot read property 'call' of undefined #555

A user does recommend using this as a possible workaround:

Can work around this by adding an empty function before creating the draw control: L.EditToolbar.Edit.prototype._editStyle = function() {};

2
  • Could you specify where exactly should I put this code?
    – Basile
    Oct 17, 2017 at 14:41
  • Try adding the empty function before creating the draw control
    – whyzar
    Oct 17, 2017 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.