getsmap / smap-responsive

A JavaScript framework for simple creation of web maps with responsive design supporting a range of different browsers and devices
GNU General Public License v3.0
14 stars 12 forks source link

Highlight remains on first feature in GeoJSON polygon layer #199

Closed WilliamWalker55 closed 8 years ago

WilliamWalker55 commented 8 years ago

The first listed feature in the GeoJSON is highlighted regardless of where the layer is clicked, it remains highlighted when selecting other features in the layer. This happens even when it is the only layer in the config file. Popups appear in the correct place and contain correct information.

{
    init: "L.GeoJSON.WFS",
    url: document.URL.search(/dev.html?/) > 0 ? "examples/data/daro.geojson" : "../examples/data/daro.geojson",
    options: {
        displayName: "Delavrinningsområde",    
        category: ["Hydrologi"],            
        layerId: "daro",                
        attribution: "",                
        inputCrs: "EPSG:4326",                      
        uniqueKey: "ID",                            
        selectable: true,                       
        reverseAxis: false,                         
        reverseAxisBbox: true,                      
        geomType: "POLYGON",
        legend:"examples/data/legend/daro_legend.jpg",                  

        style:{
            stroke: true,
            color: "#000000",
            opacity: 0.5,
            fillOpacity: 0,
            weight:1                
        },

        popup: 
            '<p>${Namn}<br/>'
    }
},
johanlahti commented 8 years ago

Hmm, I feel that I recognise this bug. First check if the uniqueKey (here given as "ID" – in capitals) is a correct attribute (it must exist). Also check that all values for given "ID" are unique. If error is still present please upload the geojson/send a link to it and I could have a look.

WilliamWalker55 commented 8 years ago

ID exists in capitals and the vaules are unique. The GeoJSON that I sent had the "ID" value as a float, I have since tried it as an interger and string but the issue is still present

johanlahti commented 8 years ago

The problem is caused by the feature ID (not the properties ID) is in upper-case. The GeoJSON standard says it should be given as "id": http://geojson.org/geojson-spec.html#feature-objects

However, it does not state explicitly (in words) that it must be lower-case. Since this problem will for sure come back and by then we have forgotten all of this, I will change the code so it allows id to be either lower-case or upper-case. Let me commit first and then update to the latest code to confirm it works for you also, before closing this issue.

WilliamWalker55 commented 8 years ago

Works with both upper and lower case now