Kha Lid
Kha Lid

Reputation: 115

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

Upvotes: 5

Views: 2660

Answers (2)

JohnyWind
JohnyWind

Reputation: 63

try this:

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

instead of

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

Upvotes: 1

David Anquetin
David Anquetin

Reputation: 181

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.

Upvotes: 3

Related Questions