0

My objective is to rotate the map around a point at the center of the bottom of the screen.

To do this, I need to know the map coordinates of that (screen) point, then do a double transformation: first - move the center and then rotate around the new center , but that all requires the knowledge of the map coordinates of the rotation point.
I have the details of the map: center, orientation, zoom level, but I can't find any reference mapping a screen position to map coordinates.

Can someone point me in the right direction please?

Sailor Al
  • 797
  • 1
  • 7
  • 20

1 Answers1

0

Answered...but bet warned, it's not simple.

I had to dig into the arcane world of Google Maps tiling, and with a bit of help from mapTiler and some re-writing of the globalMercatorClass from php to java This is how I approached it:

  • Convert the center of the screen (via meters) to pixels in the current zoom
  • Using trig, find the pixel position of the bottom, center of the screen from the screen size and the map orientation from the screen center.
  • Convert that back to Lat/Lon and use it as the camera position

It uses an extraordinary number of CPU cycles, so I have had to slow the refresh rate down to 1.5 seconds, but, hey, it's working.

It would be nice to have some of this functionality available from the API, it would probably reduce the horsepower (and brainpower) required for the job. But I'm delighted that it's possible.

Sailor Al
  • 797
  • 1
  • 7
  • 20