moagrius / TileView

TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.
MIT License
1.46k stars 337 forks source link

GPS - Enchancement #367

Closed Caspain closed 7 years ago

Caspain commented 8 years ago

Hey moagrius , I have previously mentioned this before, according to relative coordinates positioning. Your examples works perfectly , when i bound my map similarly it also works.

Though not exactly, let me expound, when i bound my coordinates south east and north west,it relatively maps the coordinates. However when i pulled live gps coordinated and then use add marker , it position is way off. eg. lat 18.02232 lon = -76.432221 , it appears the precision is up to the third digit at most.

So my question is, do you know any way mathematically or logically map the real coordinated in relation to the ones generated by the tileview(Coordinate Translator is pixel based).

moagrius commented 8 years ago

i don't know of a way off hand - there's no "curve" built in - it just takes whatever you say your left and right edges are, and find the relative position for any number between them.

i'm sure someone has done it, and you could probably customize the positioning stuff without too much trouble (by computing yourself and not using relative bounds at all), but i don't know off hand of any resources - sorry.

Caspain commented 8 years ago

I see, thank you . But for guidance, (by computing yourself and not using relative bounds at all), the map is a grid of pixels. By nature their relative. what exactly do you mean?

moagrius commented 8 years ago

all TileView does is find a relative position between edges.

if you're left edge is say 50, and your right edge is 100, and someone passes in a coordinate of 60 it will be at a point 20% between left and right.

double distance = right - left;
float relative = (coordinate - left) / distance;

that would give you 0.2, which means 20% of the way across. you then apply that to pixels to get the actual coordinate on screen:

int pixel = width * relative;

As you can see, it's a very simple system. It does not take into account the curve of the earth. That said, you can supply whatever bounds you want - or none, and compute pure pixel positions yourself - however works best for you app.