Yii Framework Forum: \dosamigos\leaflet extension - Howto make a Choropleth map - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

\dosamigos\leaflet extension - Howto make a Choropleth map Error adding javascript function in GeoJson clientOptions Rate Topic: -----

#1 User is offline   proyectotestbuk 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 20-November 17

Posted 20 November 2017 - 07:54 AM

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!!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users