An error occurred: Cannot read property 'set' of undefined
This indicates that the variable "storage" has not been defined.
To resolve this issue, make sure to declare and import "storage" correctly in the constructor as shown in this guide: Ionic Storage Docs
import { Storage } from '@ionic/storage';
export class MyApp {
constructor(private storage: Storage) { }
...
// set a key/value
this.storage.set('name', 'Max');
// Or to get a key/value pair
this.storage.get('age').then((val) => {
console.log('Your age is', val);
});
}
If the error is related to this.Marker.getPosition()
being null, you may try implementing the solution suggested by Ahkil J:
google.maps.event.addListener(Marker, 'click', (function(Marker) {
return function() {
this.LastLat = Marker.position.lat();
this.LastLng = Marker.position.lng();
this.storage.set('mylocation', this.LastLat + this.LastLng);
}
})(Marker));