Fixed center marker Maps

Hello,

I have a problem that I can not solve. I am trying to create a marker to place fixedly on the screen. Like the uber application. I use Google Maps native. I thank you if you find a solution.

The Yellow markers are fixed. The Green marker is the currently selected marker. The Blue marker is the user’s current position.

See:

Thank you for your answer, but I have already read the documentation but Ionic’s native Google maps works differently

@bankai14 The @ionic-native/google-maps does not have the feature.

But you can do:

<div id="map_canvas" style="position:relative;width:500px;height:500px;">
  <img src="marker.png" style="position:absolute;left:50%;bottom:50%;width:32px;height:18px" />
</div>
2 Likes

Thank you it’s great! But tell me please is it possible to have a function that retrieves the latitude and longitude of the center of the map? Thank you anyway !

map.getCameraTarget()

I tried but I have this:

Result screen:

Do you want to pick up the center position when you drag the map, correct?

Is your code moving any map?

I want to recover the latitude and longitude of the center of the map whenever I request it.

Something like that:

source: https://github.com/mapsplugin/cordova-plugin-googlemaps-doc/tree/master/v2.0.0/class/Map/getCameraPosition

But it dosent work with me, ionic problem ?

Please check the source code implementation before asking.

Map.prototype.getCameraPosition = function() {
  return this.get("camera");
};

I dont’t understand because this is what I did :
I did 2 solutions and none of them work.

Can you make me see a code that works, please? You will save me if you help me.

console.log(this.map.getCameraTarget())

But getCameraTarget does not exist on my object GoogleMap, whereas in the documentation it is written that it is a method of the object.

The link is not document, it is source code of @ionic-native/google-maps

It’ weard because getCameraTarget does not exist for me :confused: no other solutions ? :confused:

What did you by yourself do in order to resolve?
I recommend you should do your best as much as possible when you ask to something to other people.

I looked for the object: getCameraTarget and I did not find. I tried to display this.map.getCameraPosition () but I have a null result.

I tried with the then: this.map.getCameraPosition ()
.then ((pos) => {
alert (“on”);
alert (JSON.stringify (pos));
});

Same no result… It does not even fit in my success.

Do you think this code returns a promise?