here-api

HERE maps - Move map position


I would like to do very simple thing which is moving HERE map left / right / up / down. Let's focus on one thing, so moving map up. This works fine when dragging the map but how to do that from code?

I've tried taking current GeoBox modifying latitude only (keeping longitude unchanged) and then using:

camera.lookAt(myNewBox, new GeoOrientationUpdate(null, (double) 0));

It worked but I guess that due to spherical coordinate system map not only moved up but also to the right (of course it depends on location). Anyway, I would only like to move the map in one direction, preferably by just giving it value in px / dp. Is it possible? Or can I maybe simulate drag from code?


Solution

  • I was finally able to achieve what I needed. Initial approach with moving whole box:

    camera.lookAt(myNewBox, new GeoOrientationUpdate(null, (double) 0));
    

    resulted in map zooming out a bit (due to spherical coordinate system) because map wanted to show new corners and since earth is not flat it had to zoom out it my case. Probably in case of different coordinates it could be zooming in as well.

    In order to achieve this without zoom effect I've used different variant of lookAt function which shows single point only:

    camera.lookAt(new GeoCoordinates(centerPointLatitude + shift, centerPointLongitude));
    

    It required computing center point first but it does the job without any zoom or left / right shift.