google maps android api 2 - Converting from world coordinates to tile location -


Another friend trying to create an Android app for an add-on that uses Google Maps, and we The error is spent for one day.

Ideally the app gets updates of the user's location, archives them, and paints over any stored coordinates. This has become a nightmare to implement, we are now trying to paint on the entire tile if the tile has a coordinate which the user has seen, though we feel that some of our conversions from tile space with coordination Is wrong because as much zoom more zoom a little or a bit like a little bit of painted tile from the actual direction and a small west Su is.

  Personal boolean isCoordInTileForZoom (int tileX, et tile, int zoom) {// coordinate to check if they have existing tile float lawn = WILF_TEST_COOR.x; Float late = WILF_TEST_COOR.y; // map length and map height float map x = lon + 180 coordinates; Float Map Y = (axis * -1) + 150; // Number of tiles in a row or column (2 ^ zoom) int tiles = (Math) Math.pow (2, zoom); // Single tile double tile height and width = 360.0 / tiles width = double tile height = 180.0 / tiles; Int mapCol = (int) (mapX / tileWidth); Int mapRow = (int) (mapY / tileHyight); Log D. ("Minimap.mapGridDetails", "\ n" + "Zoom Level:" + Zoom + "\ nMovet Rows:" + Tiles + "\ nTile Width:" + Tile Wide + "\ nTile height:" + Tile height) ; If (mapCol == Tile X & MapRO == Tile Y) {back true; } Other {return false; }}   

We now believe that the world is 360 degrees and 180 degrees long, which means that at zoom level 2, each tile should have 90x45 (a 4x4 grid). And it works on zoom2 and I think that 3, but jumps in the north of the painted tile on the zoom 4 and the expected place ahead.

My feeling is that our perception is how the conversion works (we believe that Google's World Map is a well-laid flat surface which is probably our inexperienced) or Perhaps Google Maps is actually more than 180 degrees in any way, due to this being in a few days, so we thank you in advance for any advice.

Have you seen this? Although its javascript, it shows the correct coordination conversion theory.

You can also see my answer on this. The class tile projection that I provided should answer your question. You can use its method getTileBounds for example, to check whether your coordinates are inside the tile or you can use latLngToPoint method and can check, even if both the X and Y points range in 0 - is TILE_SIZE.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -