{"id":24448622,"url":"https://github.com/beastbytes/yii-leaflet","last_synced_at":"2025-04-30T23:44:30.684Z","repository":{"id":178337802,"uuid":"660664390","full_name":"beastbytes/yii-leaflet","owner":"beastbytes","description":"Yii3 widget to create maps using the Leaflet mapping library","archived":false,"fork":false,"pushed_at":"2025-01-06T11:08:57.000Z","size":153,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-30T23:44:12.183Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beastbytes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-30T14:27:55.000Z","updated_at":"2025-01-06T11:09:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"64e62e8d-900b-4b5b-a6e4-e70018cd1cda","html_url":"https://github.com/beastbytes/yii-leaflet","commit_stats":null,"previous_names":["beastbytes/leaflet","beastbytes/yii-leaflet"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beastbytes%2Fyii-leaflet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beastbytes%2Fyii-leaflet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beastbytes%2Fyii-leaflet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beastbytes%2Fyii-leaflet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beastbytes","download_url":"https://codeload.github.com/beastbytes/yii-leaflet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251801001,"owners_count":21645968,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-21T00:32:20.950Z","updated_at":"2025-04-30T23:44:30.647Z","avatar_url":"https://github.com/beastbytes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BeastBytes\\Widgets\\Yii-Leaflet\nWidget that integrates the [Leaflet](https://leafletjs.com/) JavaScript mapping library with Yii3.\n\n## Features\n\n-   For Leaflet V1.*\n-   Easy to use predefined tile providers (port of [Leaflet Providers](https://github.com/leaflet-extras/leaflet-providers))\n-   Simple popup creation for markers and vector components; just set the 'content' option\n-   Leaflet plugin support\n\nFor license information see the [LICENSE](LICENSE.md) file.\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\nphp composer.phar require --prefer-dist beastbytes/yii-leaflet\n```\n\nor add\n\n```json\n\"beastbytes/yii-leaflet\": \"*\"\n```\n\nto the require section of your composer.json.\n\n### Leaflet Package\n\nInstall Leaflet using your chosen package mananger, e.g.\n\n```\npnpm add leaflet\n```\n\n\n```\nyarn add leaflet\n```\n\nor add Leaflet to the dependencies of your package.json.\n\n```json\n\"leaflet\": \"^1.9\"\n```\n\n## Usage\nAn instance of the map widget must be assigned to a variable; this instance is used to render the HTML then\nto get the JavaScript to be registered in the view.\n\nThe widget **does not** publish or register Leaflet assets, i.e. Leaflet's JavaScript and CSS. LeafletAsset is \nprovided for use in the Yii framework.\n\nThe example below displays a map using OpenStreetMap as the tile provider. It has a marker in the centre of the map and a 5km radius circle centred on the marker; these are in a layer group that is not initially displayed. When the layer is shown using the Layers control, the centre marker can be dragged and dropped and its new position is shown - this demonstrates using component events. Three other markers are added in another layer group, and a layers and fullscreen control is added to the map; the fullscreen control is a plugin.\n\n### Example\n\n```php\nuse BeastBytes\\Widgets\\Leaflet\\Map;\nuse BeastBytes\\Widgets\\Leaflet\\controls\\LayersControl;\nuse BeastBytes\\Widgets\\Leaflet\\controls\\ScaleControl;\nuse BeastBytes\\Widgets\\Leaflet\\layers\\other\\LayerGroup;\nuse BeastBytes\\Widgets\\Leaflet\\layers\\raster\\TileProvider;\nuse BeastBytes\\Widgets\\Leaflet\\layers\\ui\\Marker;\nuse BeastBytes\\Widgets\\Leaflet\\layers\\vector\\Circle;\nuse BeastBytes\\Widgets\\Leaflet\\plugins\\Fullscreen\\FullscreenControl;\nuse BeastBytes\\Widgets\\Leaflet\\types\\Icon;\nuse BeastBytes\\Widgets\\Leaflet\\types\\LatLng;\nuse BeastBytes\\Widgets\\Leaflet\\types\\Point;\n\n// Centre of map\n$centre = new LatLng(51.772550, -4.953250);\n\n// Layer group with a marker and circle\n$centreLayerGroup = new LayerGroup([\n    new Circle($centre, [\n        'radius' =\u003e 15000,\n        'color' =\u003e \"#20ffcd\"\n    ])-\u003etooltip('15km radius'),\n    new Circle($centre, [\n        'radius' =\u003e 10000,\n        'color' =\u003e \"#3388ff\"\n    ])-\u003etooltip('10km radius'),\n    new Circle($centre, [\n        'radius' =\u003e 5000,\n        'color' =\u003e \"#573CFF\"\n    ])-\u003etooltip('5km radius'),\n    new Marker($centre, [\n        'icon' =\u003e new Icon([\n            'iconAnchor' =\u003e new Point(12, 40),\n            'iconUrl' =\u003e \"leaflet/images/marker-icon.png\",\n            'shadowUrl' =\u003e 'leaflet/images/marker-shadow.png'\n        ])\n    ])-\u003epopup('\u003cp\u003e\u003cb\u003eLittle Dumpledale Farm\u003c/b\u003e\u003c/p\u003e' .\n        '\u003cp\u003eAshdale Lane\u003cbr\u003eSardis\u003cbr\u003eHaverfordwest\u003cbr\u003ePembrokeshire\u003cbr\u003eSA62 4NT\u003c/p\u003e' .\n        '\u003cp\u003eTel: +44 1646 602754\u003c/p\u003e')\n]);\n\n$pubLayers = [];\n$pubs = [\n    [\n        'name' =\u003e 'The Cottage Inn',\n        'address' =\u003e 'Llangwm, Haverfordwest, Pembrokeshire, SA62 4HH',\n        'tel' =\u003e '+44 1437 891494',\n        'location' =\u003e [51.749151, -4.913822]\n    ],\n    [\n        'name' =\u003e 'Jolly Sailor',\n        'address' =\u003e 'Burton, Milford Haven, Pembrokeshire, SA73 1NX',\n        'tel' =\u003e '+44 1646 600378',\n        'location' =\u003e [51.7079864, -4.925951]\n    ]\n];\n\nforeach ($pubs as $pub) {\n    $pubLayers[] = new Marker($pub['location'], [\n        'icon' =\u003e [\n            'iconAnchor' =\u003e new Point(12, 40),\n            'iconUrl' =\u003e \"leaflet/images/marker-icon.png\",\n            'shadowUrl' =\u003e 'leaflet/images/marker-shadow.png'\n        ]\n    ])-\u003epopup('\u003cp\u003e\u003cb\u003e' . $pub['name'] . '\u003c/b\u003e\u003c/p\u003e' .\n        '\u003cp\u003e' . str_replace(', ', '\u003cbr\u003e', $pub['address']) . '\u003c/p\u003e' .\n        '\u003cp\u003eTel: ' . $pub['tel'] . '\u003c/p\u003e');\n}\n\n// group the pub layers\n$pubsLayerGroup = new LayerGroup($pubLayers)-\u003eaddToMap(false);\n\n$draggable = new Marker([51.786979, -4.977206], [\n        'draggable' =\u003e true,\n        'icon' =\u003e new Icon([\n            'iconAnchor' =\u003e new Point(12, 40),\n            'iconUrl' =\u003e \"leaflet/images/marker-icon.png\",\n            'shadowUrl' =\u003e 'leaflet/images/marker-shadow.png'\n        ])\n    ])\n    -\u003eaddToMap(false)\n    -\u003epopup('Drag me and see what happens'),\n    -\u003eevents([\n        'dragend' =\u003e 'function(e){const position=e.target.getLatLng();window.alert(\"Moved by \" + Math.floor(e.distance) + \" pixels\\nNew position \" + position.lat + \", \" + position.lng);}'\n    ]);\n\n$overlays = [\n    'Little Dumpledale' =\u003e $centreLayerGroup,\n    'Pubs' =\u003e $pubsLayerGroup,\n    'Draggable' =\u003e $draggable\n];\n\n$map = Map::widget()\n    -\u003eattributes([\n        'style' =\u003e 'height:800px;' // a height must be specified\n    ])\n    -\u003eoptions([\n        'center' =\u003e $centre,\n        'layers' =\u003e [\n            (new TileProvider())-\u003euse('OpenStreetMap') // base tile layer\n        ],\n        'zoom' =\u003e self::ZOOM\n    ])\n    -\u003eaddCcontrols(\n        new LayersControl(overlays: array_keys($overlays)), // layers control to control layer visibility\n        new ScaleControl()\n    )\n    -\u003eaddLayers($overlays)\n    -\u003eaddPlugins(new FullscreenControl())\n]);\n\necho $map-\u003erender();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeastbytes%2Fyii-leaflet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeastbytes%2Fyii-leaflet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeastbytes%2Fyii-leaflet/lists"}