Vcitor
Vcitor

Reputation: 21

How can I add layers to Here Maps?

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.

Upvotes: 1

Views: 1977

Answers (1)

Madis Pukkonen
Madis Pukkonen

Reputation: 1315

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.

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);

Upvotes: 2

Related Questions