Pivoting around Geojson variable symbology in Leaflet Map

21 views
Skip to first unread message

J

unread,
Dec 4, 2015, 6:29:04 AM12/4/15
to Leaflet
I currently have geoJson loaded in to a leaflet map where I want to change the variable symbolised. The symbology rules can all be the same for each variable visualised. I need to find a way of letting the user choose (a list of checkboxes maybe?) which variable to visualise and then insert the choice in to the styling function that is looking at the variable. There are 8 variables

 function doStylegtd(feature) {
   
if (feature.properties.variable1 >= 0.0 &&
            feature
.properties.variable1 <= 500.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#2b83ba',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
if (feature.properties.variable1 >= 500.0 &&
            feature
.properties.variable1 <= 1000.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#80bfab',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
if (feature.properties.variable1 >= 1000.0 &&
            feature
.properties.variable1 <= 1500.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#c7e8ad',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
if (feature.properties.variable1 >= 1500.0 &&
            feature
.properties.variable1 <= 2000.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#ffffbf',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
if (feature.properties.variable1 >= 2000.0 &&
            feature
.properties.variable1 <= 2500.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#fdc980',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
if (feature.properties.variable1 >= 2500.0 &&
            feature
.properties.variable1 <= 3000.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#f07c4a',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
if (feature.properties.variable1 >= 3000.0 &&
            feature
.properties.variable1 <= 3017.0) {

       
return {
            color
: '#000000',
            weight
: '1.04',
            dashArray
: '',
            fillColor
: '#d7191c',
            opacity
: '0.6',
            fillOpacity
: '0.6',
       
}
   
}
   
}


k_man_au

unread,
Dec 7, 2015, 4:23:30 PM12/7/15
to Leaflet

var pointLayer = L.geoJson(null, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, doStylegtd(feature));
}     
});

Reply all
Reply to author
Forward
0 new messages