UNPKG

mohsen-angular-leaflet-directive

Version:

angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps

113 lines (111 loc) 4.83 kB
<!DOCTYPE html> <html ng-app="demoapp"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="../bower_components/angular/angular.min.js"></script> <script src="../bower_components/leaflet/dist/leaflet.js"></script> <script src="../dist/angular-leaflet-directive.min.js"></script> <link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" /> <script> var app = angular.module("demoapp", ["leaflet-directive"]); app.controller("BasicGeoJSONUpdateController", [ '$scope', '$http', 'leafletData', function($scope, $http, leafletData) { angular.extend($scope, { center: { lat: 31.99, lng: -33.43, zoom: 3 }, geojson : { data: { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [ -49.92187499999999, 13.239945499286312 ], [ -49.92187499999999, 54.57206165565852 ], [ -13.7109375, 54.57206165565852 ], [ -13.7109375, 13.239945499286312 ], [ -49.92187499999999, 13.239945499286312 ] ] ] } } ] }, style: { fillColor: "green", weight: 2, opacity: 1, color: 'white', dashArray: '3', fillOpacity: 0.7 } } }); $scope.updateGeojson = function() { $scope.geojson.data = { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [ -41.8359375, 28.92163128242129 ], [ -41.8359375, 38.272688535980976 ], [ -26.015625, 38.272688535980976 ], [ -26.015625, 28.92163128242129 ], [ -41.8359375, 28.92163128242129 ] ] ] } } ] }; } }]); </script> </head> <body ng-controller="BasicGeoJSONUpdateController"> <leaflet lf-center="center" lf-geojson="geojson" width="100%" height="480px"></leaflet> <h1>GeoJSON update example</h1> <button ng-click="updateGeojson()">update GeoJSON</button> </body> </html>