How to select a marker not using mouse - Unfolding Maps

FRVFRV
edited July 2018 in Library Questions

Hi @tnagel

I was wondering if there is another method to select a marker not using the mouse (i.e. not using getFirstHitMarker (mouseX, mouseY)... More precisely, : - is there a way to select a marker by its id (i.e. the id set with the setId(id) function) ? - when it is selected is there a way to change its properties like for example colour or visibility (hiden /not hiden)

Thanks in advance for your help !

Rgds

Answers

  • For this kind of request, you need to provide an mcve, a small code sample demonstrating what you are doing so far. Also, notice there is a new forum and you should consider migrating there.

    @tnagel, it will be great to see you in the new forum as well, https://discourse.processing.org

    Kf

  • FRVFRV
    edited July 2018

    Hi kfrajer

    The question relates to the unfolding library itself, so not sure any code sample would help here.

    Still, I've been implementing a piece of soft projecting flightdata on a Map object built with UnfoldingMaps library. Below is the interaction with user that is implemented in the MouseMove() function. Basically, when marker gets hit by the mouse, the marker is selected and data attached to the marker (through its ID) get displayed on the Map. To see if a marker is selected, I'm using the built-in function ==> getFirstHitMarker(Map.mouseX, Map.mouseY), that return the ID of the marker hit by the mouse. However, on some other portion of the code (not implemented yet), I would need some internal routine to conditionaly select markers (obviously not using the mouse), change there satus (hiden/unhiden), color and size. Thus my question to @tnagel: is there any other way to identify and select a marker other than pointing the marker with the mouse. In other words, as each marker is allocated to an ID (through the builtin SetID() function), is there a way to select a marker by its ID ?

    Thanks in advance for your help,

    ///////////////////////////////////////////////////////////////////////

    Marker marker = map.getFirstHitMarker(Map.mouseX, Map.mouseY); if (marker != null) { marker.setSelected(true); display = dataEntriesMap.get(marker.getId());

    // ShowAngles(display.HSpeed,display.VSpeed,display.Alt,display.Glide,display.Acc);

    String text=display.HSpeed+"\n"+display.VSpeed+"\n"+display.Alt+"\n"+display.Glide+"\n"+display.Acc+"\n"+display.Roll+"\n"+display.Pitch; Map.textSize(18); Map.fill(255, 0,0); Map.text(text, Map.mouseX+10, Map.mouseY, 300, 300);

    ///////////////////////////////////////////////////////////////////////

  • Have you checked the example in unfolding maps?

    http://unfoldingmaps.org/tutorials/markers-simple

    As you can see there, instead of adding the marker to your current map, you could store the markers and draw them yourself. This suggestion might work for you but it really depends on how you are loading your data to create your markers and how you manage those markers in your code.

    Kf

  • Right, this is indeed the method I'm using = add a marker to a loction set color and size and then link it to additional properties listed in a hash table through a common ID. This works very well indeed...

    However this doesn't teach how to select one of the marker and then change its displaying properties (like color, hidden status, size etc...) NOT using the mouse [-X . It seems Unfolding only authorize to select a marker using the mouse (for example using the getFirstHitMarker(Map.mouseX, Map.mouseY)) = in the API doc I can't find any other selection method (I would have expected something like getMarker(ID)).

    The only approaching function I found in the API doc is markerManager.getMarkers(), which returns the list of ALL markers stored in marketManager, but does not allow to select a particular one.

    Sounds a bit stupid but I'm completely stuck...

    Fred

  • You can manually set the status, and it will be displayed in the default highlight style.

    SimplePointMarker marker = new SimplePointMarker(new Location(52.5, 13.4));

    marker.setSelected(true);

    From the link above

  • Ok, that might bring a bit of light. I would then have to recreate à new marker each time i want to change its display properties. I understand there is no way to do that on a pre existing set of marker after they have been added to à map. Right ?

  • API doc I can't find any other selection method (I would have expected something like getMarker(ID)).

    I am niot familiar with the library. The docs is the way to go at this point. If the function does not exist, then you could suggest as a feature request in github.

    The only approaching function I found in the API doc is markerManager.getMarkers(), which returns the list of ALL markers

    If you get the list of all markers, can you iterate through the list to find the one with the proper ID? That is what I will do for starters and see if I can make it work.

    Kf

  • edited July 2018

    understand there is no way to do that on a pre existing set of marker after they have been added to à map. Right ?

    No.

    Wrong.

    just use ... .setSelected(true); on the markers you got. E.g. in an array or whatever

Sign In or Register to comment.