我正在尝试在ngx-传单应用中使用风水插件(https://github.com/geoman-io/leaflet-geoman) .我已经找到了这个帖子:Integrate EasyButton, Geoman with ngx-leaflet,但是在这篇文章中提供的唯一适合我的解决方案是使用这样的括号符号:
map["pm"]["addControls"]({position: 'topleft'});
我想这不是最好的方法。那么,我的问题是如何在ngx传单中恰当地使用风水?
当我完全尝试这些步骤时,它不起作用,因为在map.pm.addControls({...}),我得到了错误
属性“pm”在“Map”类型上不存在
步骤:
npm i @geoman-io/leaflet-geoman-freeimport '@geoman-io/leaflet-geoman-free';"styles": [
"src/styles.scss",
"./node_modules/leaflet/dist/leaflet.css",
"./node_modules/@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css"
],import { BaseIconOptions, geoJSON, Bounds, CRS, Icon, icon, IconOptions, imageOverlay, latLng,
LatLngBounds, LatLngBoundsExpression, layerGroup, Map, marker, point, polyline, tileLayer } from 'leaflet';
import * as L from 'leaflet';
import 'leaflet-rotatedmarker';
import '@geoman-io/leaflet-geoman-free';
@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent {
...
onMapReady(map: Map) {
map.pm.addControls({
position: 'topleft',
drawMarker: false
});
}
}我的package.json文件:
"dependencies": {
"@angular/animations": "~10.2.0",
"@angular/cdk": "^10.2.7",
"@angular/common": "~10.2.0",
"@angular/compiler": "~10.2.0",
"@angular/core": "~10.2.0",
"@angular/flex-layout": "^10.0.0-beta.32",
"@angular/forms": "~10.2.0",
"@angular/material": "^10.2.7",
"@angular/platform-browser": "~10.2.0",
"@angular/platform-browser-dynamic": "~10.2.0",
"@angular/router": "~10.2.0",
"@asymmetrik/ngx-leaflet": "^8.1.0",
"@fortawesome/angular-fontawesome": "^0.7.0",
"@geoman-io/leaflet-geoman-free": "^2.7.0",
"@types/leaflet": "^1.5.19",
"@types/leaflet-rotatedmarker": "^0.2.1",
"leaflet": "^1.7.1",
"leaflet-rotatedmarker": "^0.2.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.1002.0",
"@angular/cli": "~10.2.0",
"@angular/compiler-cli": "~10.2.0",
"@types/node": "^12.11.1",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.6.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~5.0.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.2",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.5.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~4.0.2"
}如果我将onMapReady函数更改为onMapReady(map: L.Map),它将引发相同的错误。谢谢你帮忙!
发布于 2020-11-16 07:37:26
对我来说,它适用于脏类型any:
onMapReady(map: any)https://stackoverflow.com/questions/64769162
复制相似问题