mohsen-angular-leaflet-directive
Version:
angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps
113 lines (112 loc) • 4.38 kB
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/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
<script src="../dist/angular-leaflet-directive.min.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<link rel="stylesheet" href="../bower_components/leaflet.markercluster/dist/MarkerCluster.css" />
<link rel="stylesheet" href="../bower_components/leaflet.markercluster/dist/MarkerCluster.Default.css" />
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller("MarkersClusteringController", [ "$scope", function($scope) {
angular.extend($scope, {
center: {
lat: 24.0391667,
lng: 121.525,
zoom: 6
},
markers: {
taipei: {
layer: "northTaiwan",
lat: 25.0391667,
lng: 121.525,
},
yangmei: {
layer: "northTaiwan",
lat: 24.9166667,
lng: 121.1333333
},
hsinchu: {
layer: "northTaiwan",
lat: 24.8047222,
lng: 120.9713889
},
miaoli: {
layer: "northTaiwan",
lat: 24.5588889,
lng: 120.8219444
},
tainan: {
layer: "southTaiwan",
lat: 22.9933333,
lng: 120.2036111
},
puzi: {
layer: "southTaiwan",
lat: 23.4611,
lng: 120.242
},
kaohsiung: {
layer: "southTaiwan",
lat: 22.6252777778,
lng: 120.3088888889
},
taitun: {
layer: "southTaiwan",
lat: 22.75,
lng: 121.15
}
},
layers: {
baselayers: {
mapbox_light: {
name: 'Mapbox Light',
url: 'http://api.tiles.mapbox.com/v4/{mapid}/{z}/{x}/{y}.png?access_token={apikey}',
type: 'xyz',
layerOptions: {
apikey: 'pk.eyJ1IjoiYnVmYW51dm9scyIsImEiOiJLSURpX0pnIn0.2_9NrLz1U9bpwMQBhVk97Q',
mapid: 'bufanuvols.lia22g09'
}
}
},
overlays: {
northTaiwan: {
name: "North cities",
type: "markercluster",
visible: true
},
southTaiwan: {
name: "South cities",
type: "markercluster",
visible: true
}
}
}
});
}]);
</script>
<style>
.angular-leaflet-map {
width: 100%;
height: 320px;
}
.left {
float: left;
width: 58%;
padding-right: 1em;
}
.right {
float: right;
width: 40%;
}
</style>
</head>
<body ng-controller="MarkersClusteringController">
<leaflet lf-center="center" lf-markers="markers" lf-layers="layers" width="100%" height="480px"></leaflet>
<h1>Marker clustering example</h1>
<p>You can create a marker-clustering group on the map, defining <strong>layers</strong> and your <strong>markers</strong> definition as this example.</p>
</body>
</html>