Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Example on how to add a Polygon,Circle or Rectangle to a map #51

Open
chulu1francis opened this issue Dec 31, 2020 · 0 comments
Open

Example on how to add a Polygon,Circle or Rectangle to a map #51

chulu1francis opened this issue Dec 31, 2020 · 0 comments

Comments

@chulu1francis
Copy link

chulu1francis commented Dec 31, 2020

Trying to add a polygon to my map below is my code

 $center = new \dosamigos\leaflet\types\LatLng(['lat' => 37.7900,
          'lng' => -122.401]);
      $polygon = new dosamigos\leaflet\layers\Polygon(
              [
          'name' => 'poly',
          //'map' => 'map',
          'clientOptions' => [
              'color' => 'red'
          ]
      ]);
      $polygon->setLatLngs([
          new \dosamigos\leaflet\types\LatLng(['lat' => 37.786617, 'lng' => -122.404654]),
          new \dosamigos\leaflet\types\LatLng(['lat' => 37.797843, 'lng' => -122.407057]),
          new \dosamigos\leaflet\types\LatLng(['lat' => 37.798962, 'lng' => -122.398260]),
          new \dosamigos\leaflet\types\LatLng(['lat' => 37.794299, 'lng' => -122.395234]),
      ]);

 $leaflet->addLayer($marker)      // add the marker
                        ->addLayer($tileLayer)
                        ->addLayer($polygon);  // add the tile layer

echo $leaflet->widget(['options' => ['style' => 'min-height: 500px']]);

if i add a polygon to the leaflet, map is not showing but when i remove the polygon and just leave a marker the map is showing.
Can someone assist with a working example of adding a polygon to the map using this extension.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant