Closed xyboox closed 5 years ago
Why don't you reuse the circle?
this.circle = this.map.addCircleSync({...});
this.circle.setRadius(...);
this.circle.setCenter(...);
@wf9a5m75 in fact I ended up doing just that but I thought I say something about the remove() method in case someone else is hitting the same wall.
Strange @xyboox. I tried a very similar code to the one you provided as I am using circles extensively and it worked well for me:
@battika it works for me too if I use the code in the plugin's provided sample. But not as in the sample code I put above ( where the circle object is NOT sent through the click event but rather referenced as class level variable. Try that way.
@xyboox In order to testify, please share your project files on GitHub repository. Otherwise nobody can not check your problem.
Hello @xyboox, I am using it as class-level variable, as below
export class HomePage {
circleInst: Circle;
constructor() ...
... blah blah blah ...
addCircle() {
if (!this.circleInst) {
this.nativeMapObj.addCircle({
center: {lat: CAMERA_DEFAULT_LAT, lng: CAMERA_DEFAULT_LONG} as ILatLng,
radius: 100,
strokeColor: '#6276a5',
strokeWidth: 3,
fillColor: 'rgba(0,0,0, 0.1)'
} as CircleOptions).then((c) => {
this.circleInst = c;
this.nativeMapObj.moveCamera({target: c.getBounds()});
})
}
}
removeCircle() {
if (this.circleInst) {
this.circleInst.remove();
this.circleInst = null;
}
}
@xyboox ping
@battika key seems to be the last line of you code: this.circleInst = null; without it it gets weird ( by keep adding circles ). So thanks!
I'm submitting a ... (check one with "x")
If you choose 'problem or bug report', please select OS: (check one with "x")
cordova information: (run
$> cordova plugin list
)If you use
@ionic-native/google-maps
, please tell the package.json (only@ionic-native/core
and@ionic-native/google-maps
are fine mostly) "@ionic-native/core": "^4.20.0", "@ionic-native/google-maps": "^4.20.0",Current behavior:
circle.remove() does not remove the circle from the map Expected behavior:
to remove the circle from the map
Screen capture or video record:
Related code, data or error log (please format your code or data):
The person who share your project files on Github (or other git repository) is in faster lane than other people. Please share your project files on Github or others(Bitbucket, Gitlabs...etc). If you don't want to share your project files, please create a demo project, then share it.
Screen captures, and/or native logs(such as Logcat, xcode logs) are appreciate.
Giving much information, you are waiting time is less. Thank you for your cooperation.