Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

API to retrieve screen position of markers. #4399

Closed
dagatsoin opened this issue Mar 20, 2016 · 4 comments
Closed

API to retrieve screen position of markers. #4399

dagatsoin opened this issue Mar 20, 2016 · 4 comments

Comments

@dagatsoin
Copy link

Related: #3116.
I have a scenario where a single wkwebview (or crosswalk) view would track Mapbox dummies markers (maybe 100 max). It is for a RPG game.

My goal is to separate the heavy computing (sprites, collision, particules, etc.) for characters and monsters from the map background.

I think that the only thing I need is an API which exposes the screen position of the MB dummies markers. Is there such API?
cc @incanus

@tobrun
Copy link
Member

tobrun commented Mar 20, 2016

@dagatsoin that is a cool use-case. Would love to see the end result.

API which exposes the screen position of the MB dummies markers

Currently our markers don't expose screen position as an attribute but as a LatLng.
We support a conversion method in map.cpp that will return the screen position:

PrecisionPoint Map::pixelForLatLng(const LatLng& latLng) const {
    return transform->latLngToPoint(latLng);
}

The mentioned method is found in our core, but you are probably looking for a method found in one of our bindings (Android, iOS, OSX,..). Could you mention the binding you are using?

@friedbunny
Copy link
Contributor

Screen position ↔ map coordinate conversion functions are available in iOS — you’ll probably want -convertCoordinate:toPointToView:.

Here’s an interactive example of how to do point/coordinate conversion.

@UmairKhalid786
Copy link

UmairKhalid786 commented Apr 13, 2017

Is there any way to do it in Android SDK ? @friedbunny

@tobrun
Copy link
Member

tobrun commented Apr 13, 2017

@UmairKhalid786 You can use Projection#toScreenLocation and Projection#fromScreenLocation to convert LatLng into pixels on screen or reversed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants