How can I add layers to Here Maps? - here-api

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.

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

Related

How do I find the order of layers(z-index) rendered in mapbox

I have several custom layers rendered on the map, how do i find out which layer is top and which layer is beneath.
Suppose i have 20 custom layers rendered on the map, I need to find out which layer is above or below which layer
We can find the order of layers rendered using the map object itself.
log the map object, inside the style property, we have the _order property that contains the array of layers that are rendered on the map.
Entries in the _order array are arranged in z-index ascending order.
The first entry(layer) in _order array is beneath the second entry(layer) in _order array.
that last entry is the top most layer that appears on the map.
eg: this.map.style._order

HERE - Cluster view all items in clusterprovider

after adding all items into a clustered data provider i would like to set the bounds of the map to make sure all items are displayed.
in case of a marker group this is easy by using the bounding box of the marker group but i cant figure out what to use with a clustered data provider
H.clustering.ICluster contains method getBoundingBox() that could help to set the bounds of the map.
Reference can be taken from here :
https://developer.here.com/documentation/maps/3.1.17.0/api_reference/H.clustering.ICluster.html

Select objects on a JavaFX Pane

I've created an application to draw objects on a JavaFX pane (rectangle, paths, custom controls etc..).
Now I want to be able to select those objects to move, copy or group them. The javafx Pane don't have a selectionModel by default and I somehow didn't find out how to implement such function.
If someone got an Idea on how to do this, I'll be grateful
You need to create your own selection model.
First you create a class SelectionModel. In that you put a Set. In order to put nodes into that set, you have to create a mouse handler that adds nodes to the model and removes them from the model depending on shift/ctrl pressed while you click on the nodes.
When you move the selection via mouse, you get the position of the currently clicked on node and instead of moving the single node in the event handler you move all nodes of the list in the SelectionModel.
In order to group them, you need to create a class/collection in which you can store the various nodes you selected. Usually the group is just a parent node. But that varies depending on your requirements.
Copy/Paste is a different matter. You need to create some kind of factory that creates and positions new nodes depending on the nodes in your selection model.
Here's an example with code for a start. It shows you how to select nodes.

Getting marker data from a google map v3

I have a google map v3 with a number of markers, which have a "category" attribute. I also have a left side menu bar, from which a user can select the desired category. When he/she clicks on the selected category, all the markers are cleared from the map, and only markers with the selected category are loaded.
Now, I need some sort of function which can search through the map and get the loaded markers and their data. The data will then be dynamically loaded in the right side menu bar. You can see the page I am talking about at this LINK
Please, any help will be highly appreciated...
I know this isn't the answer you are hoping for, but there is no good way to query the map and ask for all of the markers. As you load the map and create the markers, you want to keep an array of all of your markers or keep an array by category and track your markers in multiple arrays. Keeping an array for each marker type will make it much easier to turn them on/off; that's what I do. Hope this helps -
One solution:
1) Create an array of markers. Every time you create a marker, add it to the array. Also assign a property to the marker of 'category' or something.
marker.category='foo';
2) When user clicks on the button, look through your markers array and test if each marker matches the category. If it does not, set the map to null.
if (markers[iterator].category!='foo'){
markers[iterator].setMap(null);
} else {markers[iterator].setMap(map);}

AdvancedDataGrid (grouping) quick jump to row

I have a problem with the AdvancedDataGrid widget. When the dataProvider is an ArrayCollection (of arrays), the nth array (within the collection) is also the nth row within the grid, and I can jump and display the i-th row by scripting
adg.selectedIndex = i;
adg.scrollToIndex(i);
now, when I add a Grouping, the dataProvider ends up being a GroupingCollection2, and now the index in the dataprovider's source does not correspond to the index in the adg anymore (which is understandable, because it's being grouped).
How can I select and display a row in grouped data efficiently? Currently, I have to traverse the adg and compare each found item with its data attributes in order to find the correct index of the row within the adg, and jump to it like above. This process is very slow. Any thoughts?
edited later:
We already used a caching object as Shaun suggests, but it still didn't compensate for the search times. In order to fully construct a sorting of a list of things (which this problem equates to, as the list is completely reordered by the grouping), you always have to know the entire set. In the end we didn't solve that problem. The project is over now. I will accept Shaun's answer if no one knows a better way in three days.
Depending on what values your comparing against you can store the objects in a dictionary with the lookup using the property/properties that would be searched for, this way you have a constant time look-up for the object (no need to look at every single item). Say for example your using a property called id on an object then you can create an AS object like
var idLookup:Object = {};
for(myObject in objects)
idLookup[myObject.id] = myObject;
//Say you want multiple properties
//idLookup[myObject.id]={};
//idLookup[myObject.id][myObject.otherProp] = myObject;
now say the user types in an id you go into the idLookup object at that id property and retrieve the object:
var myObject:Object = idLookup[userInput.text];
myAdg.expandItem(myObject, true);
now when you want to get an object by id you can just do
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/controls/AdvancedDataGrid.html#expandItem()
I haven't done any thorough testing of this directly, but use a similar concept for doing quick look-ups for advanced filtering. Let me know if this helps at all or is going in the wrong direction. Also if you could clarify a bit more in terms of what types/number of values you need to lookup and if there's the possibility for multiple matches etc. I may be able to provide a better answer.
Good luck,
Shaun

Resources