2

I want to create something in android like this: http://openlayers.org/dev/examples/wmts-getfeatureinfo.html I'm able to load the custom tiles with WMTS but now I need to get data to show in some kind of a popup window when clicked (touched).

I found that you can get extra info with the service getFeatureInfo, for this request i need some extra parameters like "I" and "J".

Which are the number of pixels from the bottom-left point of the tile to the clicked position on the tile?

I have no idea how I can get these parameters in android.

1 Answer 1

2

For those who are still interested in the answer. I've calculated the pixel coordinates with the following formula:

int zoom = (int) mMap.getCameraPosition().zoom;

    double sinLatitude = Math.sin(ltln.latitude * Math.PI / 180);
    int pixelX = (int) (((ltln.longitude + 180) / 360) * 256 * (Math.pow(2,zoom)));
    int pixelY = (int) ((0.5 - Math.log((1 + sinLatitude)/ (1 - sinLatitude))/ (4 * Math.PI)) * 256 * (Math.pow(2, zoom)));

    // calculate pixel coordinates on tile
    int i = pixelX % 256;
    int j = pixelY % 256;

    // calculate x and y coordinate tile
    int x = pixelX / 256;
    int y = pixelY / 256;

Here you get the x and y coordinates from the clicked tile and the pixel coordinates of your marker on the tile.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.