-
Notifications
You must be signed in to change notification settings - Fork 632
/
Copy path0122-basic-geojson-update-example.html
112 lines (111 loc) · 4.79 KB
/
0122-basic-geojson-update-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!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="../bower_components/angular-simple-logger/dist/index.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 center="center" geojson="geojson" width="100%" height="480px"></leaflet>
<h1>GeoJSON update example</h1>
<button ng-click="updateGeojson()">update GeoJSON</button>
</body>
</html>