\dosamigos\leaflet extension - Howto make a Choropleth map

Hi all!

I’m newbie with YII2 and I’m having a lot of problems adding Javascript functions inside object properties because I really don´t understand how the framework work in the backstage.

More to the point, I’m using Leaflet javascript library through awesome 2amigos extension but I’ve failed all syntactic tries to add javascript functions to my GeoJson class through clientOptions.

Lots of hours spent in vain so far…

Any help?

This is the code I’m trying




$capaProvincias = new \dosamigos\leaflet\layers\GeoJson([	

		'data' => $geojson,

		'clientOptions' => [

			'style' => 'js:function(feature) {

				switch (feature.properties.Cod_Prov) {

					case "06": return {color => "#ff0000"};

					case "18": return {color => "#ffff00"};

					case "41": return {color => "#ff00ff"};

				}

			}',

		],

	]);	



The map is rendered perfectly but without any interaction :(

Thanks in advance!!