Thread: [SailfishOS] Mapbox GL Native QML plugin
View Single Post
Posts: 1,414 | Thanked: 7,547 times | Joined on Aug 2016 @ Estonia
#73
Originally Posted by m4r0v3r View Post
sorry I mean how do I get the centre coords. I have a pin in the center of the screen, I move the map underneath the pin so lat and lng will change. how can I get the lat lng the pin is now at?
Sorry, I misunderstood. I assume that you write an app and want to know API, right?

To get coordinate of any pixel, you call method

Code:
queryCoordinateForPixel(const QPointF p, const QVariant &tag = QVariant())
This method will return immediately and the reply you will get somewhat later (has to go through to other thread and so on) via signal

Code:
replyCoordinateForPixel(const QPointF pixel, QGeoCoordinate geocoordinate, qreal degLatPerPixel, qreal degLonPerPixel, const QVariant &tag)

The signal will carry correct geocoordinate as well as its derivative per pixel (if you wish to apply some sensitivity analysis to the result).

See query example at https://github.com/rinigus/mapbox-gl...es-and-signals

So, in your case, find pixel coordinates of the pin and ask for its geolocation using queryCoordinateForPixel
 

The Following User Says Thank You to rinigus For This Useful Post: