我尝试将 GeoJson 文件导入到 angular 应用程序 6 中的传单中。
使用此解决方案,我的 geojson 是在传单图中绘制的,但出现此错误,我无法构建我的应用程序。有人知道一种解决方案吗?
错误 TS2345 类型参数 '{"type": string;"features":({"type": string; "geometry": { "type: string : "coordinates": num...' 不是类型的可分配参数GeoJson 对象
模型.ts
export const Pdl = [ 'my geojson' ];
Run Code Online (Sandbox Code Playgroud)
组件.ts
import { LeafletModule } from '@asymmetrik/ngx-leaflet';
import * as L from 'leaflet';
import {Pdl} from "../models/pdl.model";
@Component({
selector: 'app-geo',
templateUrl: './geo.component.html',
styleUrls: ['./geo.component.scss']
})
export class GeoComponent implements OnInit {
ngOnInit() {
var mapboxAccessToken = "...";
const myfrugalmap = L.map('frugalmap').setView([47.482019, -1], 7);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + …Run Code Online (Sandbox Code Playgroud) 我遵循本教程: https: //leafletjs.com/examples/choropleth/
当我将鼠标悬停在地图上的 Geojson 上时,我尝试制作自定义控件。
但我在“info = L.control();”上遇到错误
无法调用类型缺少调用签名的表达式。类型“控制类型”没有兼容的调用签名。
有人可以帮我翻译一下吗?谢谢你的帮助。
var mapboxAccessToken = "key";
const myfrugalmap = L.map('frugalmap').setView([47.482019, -2], 7.5);
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=' + mapboxAccessToken, {
id: 'mapbox.light',
attribution: 'SOS'
}).addTo(myfrugalmap);
this.http.get('assets/departements.json').subscribe((json: any) => {
console.log(json);
this.json = json;
var geojson;
geojson = L.geoJSON(this.json, {
style: function(feature) {
switch (feature.properties.code) {
case '44': return {color: "white",fillColor:"red", fillOpacity: 0.1};
case '53': return {color: "white",fillColor: "yellow", fillOpacity: 0.1};
case '72': return {color: "white",fillColor: "orange", fillOpacity: 0.1};
case '85': return {color: "white",fillColor: "green", fillOpacity: …Run Code Online (Sandbox Code Playgroud) 我有一个图像(在材料卡内)每 30 秒改变一次。我有图像的高度(作为 TS 变量),我想将其设置为加载图像的高度。我尝试了以下方法,但我认为语法是错误的。什么是正确的做法?
@Component({
selector: 'app-live',
templateUrl:
<mat-card [ngStyle]="{'min-height': '{{taille}}'}">
<img mat-card-image [src]="profileUrl | async " alt="Streaming de la culture" #img [ngStyle]="{'padding-top':'0px' }" (load)="dosomething(img)">
</mat-card>
export class LiveComponent implements OnInit {
taille;
dosomething(img) { console.log(img.clientWidth, img.clientHeight);
this.taille = img.clientHeight;
console.log(this.taille);}
Run Code Online (Sandbox Code Playgroud)