我在运行使用map和mapOptions的ionic 2应用程序时遇到问题,

时间:2017-11-11 10:32:24

标签: google-maps typescript ionic-framework

return this.loadMap().then(() => {
  const myLatLng = new google.maps.LatLng(opts.lat, opts.lon);
  const styleArray = [
    {
      featureType: 'poi',
      elementType: 'labels',
      stylers: [
        {visibility: 'off'}
      ]
    }
  ];

  const mapOptions: google.maps.MapOptions = { // this variable gives error
    zoom: opts.zoom,
    minZoom: opts.zoom,
    center: myLatLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    disableDefaultUI: true,
    scaleControl: false,
    styles: styleArray,
    zoomControl: false,
    zoomControlOptions: {
      position: google.maps.ControlPosition.BOTTOM_CENTER
    }
  };

  this.map = new google.maps.Map(mapEl, mapOptions);
  return this.map;
});
}

运行时错误

错误:

  

输入'{zoom:number; minZoom:数字;中心:LatLng; mapTypeId:MapTypeId; disableDefaultUI:true; sc ...'不能分配给'MapOptions'类型。属性“样式”的类型是不兼容的。输入'{featureType:string; elementType:string; stylers:{visibility:string; } []; } []'不能赋值为'MapTypeStyle []'。输入'{featureType:string; elementType:string; stylers:{visibility:string; } []; }'不能赋值为'MapTypeStyle'。属性“elementType”的类型不兼容。类型'string'不能分配给'MapTypeStyleElementType'

类型

截图:

Screenshot

0 个答案:

没有答案