Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type 'Promise<void>' is not assignable to type 'Marker'. Property '_objectInstance' is missing in type 'Promise<void>'. Ionic 2

I tried to apply what is in the docs gor the google maps in ionic 2 as it is in the official site: Ionic Docs Google Maps

I got this error:

Type 'Promise<void>' is not assignable to type 'Marker'. Property '_objectInstance' is missing in type 'Promise<void>'. Ionic 2

as it is figured in the screenshot below: enter image description here

like image 655
Kha Lid Avatar asked Apr 01 '17 21:04

Kha Lid


2 Answers

I had this error too, and the solution i've found is to not use marker variable, but only write

map.addMarker(markerOptions).then(...)

And it works, my marker was displayed.

like image 115
David Anquetin Avatar answered Nov 12 '22 10:11

David Anquetin


try this:

 map.addMarker(markerOptions)
   .then((marker: Marker) => {
     marker.showInfoWindow();
   });

instead of

 const marker: Marker = map.addMarker(markerOptions)
   .then((marker: Marker) => {
     marker.showInfoWindow();
   });
like image 36
JohnyWind Avatar answered Nov 12 '22 08:11

JohnyWind