使用 Leaflet.Graticule 和 angular-leaflet-directive
using Leaflet.Graticule with angular-leaflet-directive
我不知道如何将 Leaflet.Graticule 集成到 ui-leaflet/angular-leaflet-directive 应用程序中。任何关于如何完成此操作的指示将不胜感激。
编辑:为了稍微扩展 iH8 的答案,我还必须在 bower.json:
的覆盖部分添加一个条目
"overrides": {
"leaflet.Graticule": {
"main": [
"src/L.Graticule.js"
]
}
}
将 leafletData
注入您的控制器并使用它的 getMap
承诺获取 L.Map
实例并添加标线:
angular.module('App', [
'ui-leaflet'
]);
angular.module('App').controller('Controller', [
'leafletData',
function (leafletData) {
leafletData.getMap().then(function (map) {
L.graticule().addTo(map);
});
}
]);
body {
margin: 0;
}
html, body, .leaflet-container {
height: 100%;
}
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>document.write('<base href="' + document.location + '" />');</script>
<link type="text/css" rel="stylesheet" href="//cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script type="application/javascript" src="//cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script type="application/javascript" src="//rawgit.com/turban/Leaflet.Graticule/master/L.Graticule.js"></script>
<script type="application/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.js"></script>
<script type="application/javascript" src="//rawgit.com/nmccready/angular-simple-logger/master/dist/angular-simple-logger.js"></script>
<script type="application/javascript" src="//rawgit.com/angular-ui/ui-leaflet/master/dist/ui-leaflet.js"></script>
</head>
<body ng-controller="Controller">
<leaflet></leaflet>
</body>
</html>
我不知道如何将 Leaflet.Graticule 集成到 ui-leaflet/angular-leaflet-directive 应用程序中。任何关于如何完成此操作的指示将不胜感激。
编辑:为了稍微扩展 iH8 的答案,我还必须在 bower.json:
的覆盖部分添加一个条目 "overrides": {
"leaflet.Graticule": {
"main": [
"src/L.Graticule.js"
]
}
}
将 leafletData
注入您的控制器并使用它的 getMap
承诺获取 L.Map
实例并添加标线:
angular.module('App', [
'ui-leaflet'
]);
angular.module('App').controller('Controller', [
'leafletData',
function (leafletData) {
leafletData.getMap().then(function (map) {
L.graticule().addTo(map);
});
}
]);
body {
margin: 0;
}
html, body, .leaflet-container {
height: 100%;
}
<!DOCTYPE html>
<html ng-app="App">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script>document.write('<base href="' + document.location + '" />');</script>
<link type="text/css" rel="stylesheet" href="//cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script type="application/javascript" src="//cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script type="application/javascript" src="//rawgit.com/turban/Leaflet.Graticule/master/L.Graticule.js"></script>
<script type="application/javascript" src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.js"></script>
<script type="application/javascript" src="//rawgit.com/nmccready/angular-simple-logger/master/dist/angular-simple-logger.js"></script>
<script type="application/javascript" src="//rawgit.com/angular-ui/ui-leaflet/master/dist/ui-leaflet.js"></script>
</head>
<body ng-controller="Controller">
<leaflet></leaflet>
</body>
</html>