简体   繁体   English

removeMapObject方法在android premium HERE SDK 3.2.2中不起作用

[英]removeMapObject method does not work in android premium HERE SDK 3.2.2

I changed the android premium HERE SDK 3.2.1 to 3.2.2 now i face a problem in clear routes. 我将android premium HERE SDK 3.2.1更改为3.2.2,现在我在清晰的路线中遇到问题。

for(int i = 0 ; i < list_routes.size() ; i++)
{
    MapRoute mapRoute = new MapRoute(list_routes.get(i).getRoute());
    m_map.removeMapObject(mapRoute);
}

This snippet code works for 3.2.1 but not working in 3.2.2. 此代码段适用于3.2.1,但不适用于3.2.2。 I replaced jniLibs folder and HERE-sdk jar of 3.2.2 in my project. 我在项目中替换了jniLibs文件夹和3.2.2的HERE-SDK jar

This should not have worked regardless of 3.2.1 and 3.2.2. 无论3.2.1和3.2.2,这都不应该起作用。 It was probably a bug that it even worked before. 这可能是以前甚至可以解决的错误。

Calling new on MapRoute creates a handle to a natively backed object. 在MapRoute上调用new会创建一个本机支持的对象的句柄。 Your sample code implies you added the MapRoute also in this manner but never kept a handle to them. 您的示例代码暗示您也以这种方式添加了MapRoute,但从未对其进行处理。

Each MapRoute object is unique, and therefore the "new" keyword has no association to any previously added objects. 每个MapRoute对象都是唯一的,因此“ new”关键字与任何以前添加的对象都没有关联。

The correct solution should be: 正确的解决方案应该是:

    // Keep the list of MapRoute Objects.
    List<MapRoute> routes = new ArrayList<MapRoute>();
    for(int i = 0 ; i < list_routes.size() ; i++)
    {
        MapRoute mapRoute = new MapRoute(list_routes.get(i).getRoute());
        routes.add(mapRoute);
        m_map.addMapObject(mapRoute);
    }
    // Later when you want to remove the routes.
    for(int i = 0 ; i < list_routes.size() ; i++)
    {
        m_map.removeMapObject(routes[i]);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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