【发布时间】:2018-12-27 13:29:53
【问题描述】:
我是使用 Ionic 3 使用 Cordova 的 Native Google Maps API 的新手,我想知道使用按钮删除多边形、标记、圆形等的方法,例如。
实际上,我在一个名为loadMap() 的方法中创建了一个多边形并且它可以工作。但我希望能够通过另一种方法,如removePolygon(),删除多边形。
我的loadMap()code 如下:
loadMap() {
let mapOptions: GoogleMapOptions = {
camera: {
target: {
lat: 39.695263,
lng: 3.017571
},
zoom: 8,
}
};
this.map = GoogleMaps.create('map_canvas', mapOptions);
let myPolygonCoord: ILatLng[] = [
{
lat: 39.81952717082459,
lng: 3.1078016219598794
},
{
lat: 39.7794339492445,
lng: 3.0212842879755044
},
{
lat: 39.66007130788319,
lng: 3.1476270614130044
},
{
lat: 39.72030660365558,
lng: 3.2739698348505044
}
];
let myPolygon: PolylineOptions = {
'points': myPolygonCoord,
'strokeColor': '#89c3eb',
'fillColor': '#89c3eb',
'strokeWidth': 2
};
this.map.addPolygon(myPolygon).then((polygon: Polygon) => {});
}
另一方面,关于removePolygon()的方法:
removePolygon(){
//how to call the map and remove the polygon?
}
任何帮助将不胜感激。
【问题讨论】:
标签: google-maps cordova ionic-framework polygon