简体   繁体   中英

Here Map SDK OffscreenRenderer add map route glitch

I'm using the Here Android SDK API. I have two map view instances - one normal map with mapFragment (map_1) and another with OffscreenRenderer running inside android service (map_2). 在此处输入图片说明

Hope this scheme will provide some explanations. When at Activity user create Route it sends to MyApplication instance and then to bounded service where :

offscreenMap.addMapObject(route);

After start this works perfect. But when Activity gets destroyed and recreated, in the same use case, same methods at service get called (I see the logs that my route reach Service instance), but offscreenMap not instantly updated. There is some long arbitary time can happens before the map actually get updated with new route.

And whats more interesting, If user zoom out-in activity map instance heavily (or rotate the map), the map_2 gets updated with new route instantly. So my question is - Is this a Here bug or mine misuse? And what can I try to do to prevent this from happening?

Again, its not the problem of android destroying my services or lost connections to bounded services, this works fine. I can see that service methods get called.

Hope for any suggestions.

Updated: For normal case problem solved (thanks David Leong): to tell map instance that it needed to be updated, setZoomLevel(getZoomLevel()) methods helps. But! If at the same case NavigationManager running at Roadview navigation mode - map still don't updated.

Some code for clarification for map2 instance. when service started:

positionManager = PositioningManager.getInstance();
positionManager.start(PositioningManager.LocationMethod.GPS_NETWORK);

navMngr = NavigationManager.getInstance();
navMngr.setMap(map2);
navMngr.setMapUpdateMode(NavigationManager.MapUpdateMode.ROADVIEW);
navMngr.startTracking();

When route added (or changed):

public void addRoute(Route route) {
    Log.d(TAG, "addRoute");

    MapRoute mainRoute = new MapRoute (route);

    if (currentRoute != null) {
        map2.removeMapObject(currentRoute);
    }
    currentRoute = mainRoute;

    map2.addMapObject(currentRoute);
    map2.setZoomLevel(map2.getZoomLevel());

    //navMngr.stop();
    navMngr.startNavigation(currentRoute.getRoute());
}

While Activity first created and alive - this code works. But when its get destroyed and recreated, map2 gets updated only after map1 (at activity) zoom-out-in by user. Do I do something wrong with navManager?

Updated2: Get it. I used navManager for map1 and for map2. this was a mistake. It probably a singletone and should be used only for one map instance. When I restarted the activity its catch navigation manager to its own map and then map2 refreshed only accidentally. So I remove using of navigation manager on map1 and its works now. Also its pretty frustratingly that I can't use navigation manager for both maps =(

The answer to your updated problem is to write your own RoadView. It is actually quite easy and several of our customers do that!

Whenever navigation manager has an updated position, you can update the position of both maps simultaneously. Our roadview is only designed to drive one map instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM