-
Notifications
You must be signed in to change notification settings - Fork 632
/
Copy path0121-basic-double-map-toggle-example.html
85 lines (84 loc) · 3.13 KB
/
0121-basic-double-map-toggle-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
<!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.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<style>
.map {
float: left;
margin-right: 1em;
}
</style>
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller("BasicDoubleMapToggleController", [ "$scope", "$log", "leafletData", function($scope, $log, leafletData) {
angular.extend($scope, {
center: {
lat: 51.505,
lng: -0.09,
zoom: 5
},
paths: {
p1: {
color: 'blue',
weight: 8,
latlngs: [{
lat: 51.50,
lng: -0.082
}, {
lat: 48.83,
lng: 2.37
}, {
lat: 41.91,
lng: 12.48
}]
}
},
});
angular.extend($scope, {
center2: {
lat: 51.505,
lng: -0.09,
zoom: 5
},
tiles2: {
name: 'Mapbox Outdoors',
url: 'http://api.tiles.mapbox.com/v4/{mapid}/{z}/{x}/{y}.png?access_token={apikey}',
type: 'xyz',
options: {
apikey: 'pk.eyJ1IjoiYnVmYW51dm9scyIsImEiOiJLSURpX0pnIn0.2_9NrLz1U9bpwMQBhVk97Q',
mapid: 'bufanuvols.lia3no0m'
}
},
paths2: {
p1: {
color: 'red',
weight: 8,
latlngs: [{
lat: 51.50,
lng: -0.082
}, {
lat: 48.83,
lng: 2.37
}, {
lat: 41.91,
lng: 12.48
}]
}
},
});
}]);
</script>
</head>
<body ng-controller="BasicDoubleMapToggleController">
<leaflet ng-if="togglemap" id="map1" center="center" paths="paths" width="100%" height="480px"></leaflet>
<leaflet ng-if="!togglemap" id="map2" center="center2" tiles="tiles2" paths="paths2" width="100%" height="480px"></leaflet>
<h1>Toggle between two maps on screen</h1>
<p>View javascript console while toggling map</p>
<button ng-click="togglemap = !togglemap">Toggle Map</button>
</div>
</body>
</html>