Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript Ionic生成:类型“”上不存在属性“”_Typescript_Ionic3_Leaflet - Fatal编程技术网

Typescript Ionic生成:类型“”上不存在属性“”

Typescript Ionic生成:类型“”上不存在属性“”,typescript,ionic3,leaflet,Typescript,Ionic3,Leaflet,当我尝试在ionic3中构建此代码时,它会向我显示以下警报: 类型“MapService”上不存在属性“tempIcon” 离子构建 import { Injectable } from "@angular/core"; import { BaseLayersService } from "./base-layers.service"; import { WmsLayersService } from "./wms-layers.service"; import { ToastControlle

当我尝试在ionic3中构建此代码时,它会向我显示以下警报: 类型“MapService”上不存在属性“tempIcon”

离子构建

import { Injectable } from "@angular/core";
import { BaseLayersService } from "./base-layers.service";
import { WmsLayersService } from "./wms-layers.service";
import { ToastController } from 'ionic-angular';
import L from "leaflet";

@Injectable()
export class MapService {
public map: L.Map;
constructor(private wmsLayersService: WmsLayersService, private baseLayersService: BaseLayersService, public toastCtrl: ToastController) {
}
loadMap() {

  this.tempIcon = L.icon({
        iconUrl: 'assets/imgs/position.png',
        shadowUrl: '',
        iconSize: [48, 48], // size of the icon
        shadowSize: [0, 0], // size of the shadow
        iconAnchor: [48, 48], // point of the icon which will correspond to markers location
        shadowAnchor: [0, 0], // the same for the shadow
        popupAnchor: [48, 48] // point from which the popup should open relative to the iconAnchor
    });

const map = L.map("map", {
  //layers: [this.baseLayersService.baseLayers.OpenStreetMap, this.wmsLayersService.wmsLayers.Falabella]
   layers: [this.wmsLayersService.wmsLayers.Falabella, this.baseLayersService.baseLayers.CartoDB ] 
});

L.control.layers(this.baseLayersService.baseLayers, this.wmsLayersService.wmsLayers).addTo(map);
L.control.scale().addTo(map);

我想你没有申报。试着把它说成

public map: L.Map;
public tempIcon: any;