Closed proyectotestbuk closed 6 years ago
Finally resolved with:
'clientOptions' => [ 'style' => new JsExpression ('function(feature) { switch (feature.properties.Cod_Prov) { case 6: return {color: "red"}; break; default: return {color: "blue"}; } }') ]
@proyectotestbuk very happy you found the issue and really sorry for not being able to be more responsive.
Hi! Thanks for this fantastic extension.
I'm really lost with Javascript and definetely don't know how to add functions described in: http://leafletjs.com/examples/choropleth/ in my \dosamigos\leaflet\layers\GeoJson
I can set color using
$capaProvincias = new \dosamigos\leaflet\layers\GeoJson([ 'data' => $geojson, 'clientOptions' => [ 'style' => [ 'color' => 'green' ], ], ]);
but I need different colors for each feature. Something like this:
$capaProvincias = new \dosamigos\leaflet\layers\GeoJson([ 'data' => $geojson, 'clientOptions' => [ 'style' => 'js:function(feature) { switch (feature.properties.Cod_Prov) { case "01": return {color => "#ff0000"}; case "02": return {color => "#ffff00"}; case "03": return {color => "#ff00ff"}; } }', ], ]);
Lots of hours lost working in this thing due to my incompetency! :-(
Thanks in advance!