2amigos / yii2-leaflet-extension

Yii 2 Extension library to display interactive maps with Leaflet .
http://yiiwheels.com
Other
30 stars 26 forks source link

How to add an event to a polygon? #45

Open 4khobta opened 5 years ago

4khobta commented 5 years ago
$polygon = new Polygon(['name'=>'poly','map'=>'map']);
$polygon->setLatLngs([$poly1, $poly2, $poly3, $poly4]);
$polygon->clientEvents = ['click' => "function(e) {alert(1)}"];

but return wrong js without event:
map.addLayer(var poly = L.polygon([[50.07300647938297,31.440094543457036],[50.07300647938297,31.438094543457034],[50.074006479382966,31.438094543457034],[50.074006479382966,31.440094543457036]], 
tonydspaniard commented 5 years ago

@4khobta you just found a bug. Forgot to collect events.

egutierrezr421 commented 4 years ago

this code worked for me. I created a class by extending the Polygon class and modified the encode function as seen in the image. 1593307904029545111095393589527