[英]PascalCase to camelCase, Finding and replacing in an angular proj
[英]Proj4Leaflet angular 5
我讀了不同的主題,但是沒有用。 我想在角投影中使用leaftlet和Proj4Leaflet進行投影espg
import * as L from 'Proj4Leaflet';
const crs = new L.Proj.CRS('EPSG:3006',
'+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs',
{
resolutions: [
8192, 4096, 2048, 1024, 512, 256, 128
],
origin: [0, 0]
});
const myMap = L.map('map').setView([46.2, 2], 6);
myMap.options.crs = crs;
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: 'My Map'
}).addTo(myMap);
this.http.get('../assets/data.json')
.subscribe(data => {
console.log(data);
const lMyGeoJson = L.geoJSON(<any>data, <any>{
style: function(feature, layer) {
return {
weight: 1,
opacity: 1,
color: '#66CC66'
};
}
}).addTo(myMap);
console.log(lMyGeoJson);
} );
地圖未顯示,我在執行中出現錯誤
TypeError:L.map不是函數
謝謝你提前
您還需要導入@types/proj4leaflet
軟件包。 它包含Proj4Leaflet導出代碼的TypeScript聲明。
// In package.json
...
"@types/proj4leaflet": "^1.0.5",
...
"proj4leaflet": "^1.0.2",
...
// In .angular-cli.json
"../node_modules/proj4leaflet/lib/proj4.js",
"../node_modules/proj4leaflet/src/proj4leaflet.js",
// In your app.module.ts
declare var require: any;
require('proj4leaflet');
// Importing in your .ts code
import {Map, Proj} from "leaflet";
// Creating the CRS:
let crs = new Proj.CRS(...);
編輯仍然對我不起作用
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.