views:

28

answers:

1

As part of a mapping application, I am implementing a crude sort of tiling. I am looking for an efficient way to know which tiles need to be loaded according to the current map view port.

In order to do that, I thought of taking the point in the center of the map (for example) and loading the tile for that point.

I need an algorithm for mapping any point on the map to a specific tile.

+1  A: 

If your tiles all have the same size, just use an integer divide to get the index of the tile.

Note that you will have to map the coordinates of the point into map coordinates, first (i.e. you must shift it by the offset of the tiles in your view).

Aaron Digulla
Thanks! Now why didn't I think of that?
Ovesh

related questions