如何在“这里地图"中添加图层? [英] How can I add layers to Here Maps?

查看:132
本文介绍了如何在“这里地图"中添加图层?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从here-api开始,我按照示例操作,并在地图上添加了一些标记,但是我选择了nedd和一个图层切换器,以选择具有不同标记的多个图层,并在地图上显示了它,但我做不到它.标记是静态的,地图不会重新加载firt标记.

I am starting with here-api,I follow the examples and I add some markers in the map, but i nedd and a layer switcher, to select multiple layers with differents markers, and shown it in the map but i cant do it. The markers are, static and the map not reload the firt markers.

我尝试在选项卡中放置多个地图,但不起作用.有什么想法吗?

I try to put more than one maps, in tabs, but not work. Some idea about it?

对不起,我的英语. 问候.

Sorry for my english. Regards.

推荐答案

据我所知,这里JS API不支持这种开箱即用的层,但是您可以实现的非常简单. 您可以使用称为 Group 的内容.

As much as I know, Here JS API does not support this kind of layers out of the box, but you can implement is quite simply. You can use something called a Group.

文档中: 是逻辑容器,可以容纳子对象(标记或空间, 还有子组).通过组,可以轻松地在其中添加,删除,显示或隐藏整套地图对象 原子操作,无需单独操作每个对象.另外,一组 允许您计算包围它包含的所有对象的边界框并侦听事件 由小组的子对象分派.

From the documentation: Groups are logical containers which can hold a collection of child objects (markers or spatials, but also sub-groups). Groups make it easy to add, remove, show or hide whole sets of map objects in an atomic operation, without the need to manipulate each object individually. In addition, a group allows you to calculate a bounding box enclosing all the objects it contains and to listen for events dispatched by the group's child objects.

这意味着您可以将一些对象(标记,折线,多边形)添加到一个组中,而将一些对象添加到另一组中.然后,您可以在地图上相应地使用 addObject removeObject 方法来添加或删除该组(组扩展了Object类).

It means that you can add some objects (markers, polylines, polygons) into one group and some into another group. Then you can use addObject and removeObject methods on the map accordingly to add or remove this group (group extends Object class).

group = new H.map.Group();
group.addObject(marker1);
group.addObject(marker2);

// add to map
map.addObject(group);

// remove from map
map.removeObject(group);

这篇关于如何在“这里地图"中添加图层?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆