Topic: How to modify a certain group 2D of markers?

Hello,

Is there a way to display/hide/modify(change color) of a certain group of 2D markers and not all of them?

Is it possible to do this with 2D markers created through the inspector, or in this case markers should be created through the code?

I think as an option I could create the markers via the script and add a specific tag to them in order to manipulate them later.
Is there another way designed for Online Maps?

Thank you!

Re: How to modify a certain group 2D of markers?

Hello.

You can use OnlineMapsMarkerBase.tags or OnlineMapsMarkerBase.customData to store the group ID (or other information that you need to define a marker group).
You have direct access to the array of markers, so you can easily make a selection, for example (LINQ):

foreach (OnlineMapsMarker marker in OnlineMaps.instance.markers.Where(m => m.tags.Contains("mytag")))
{
    // do something
}

or

string groupID = "mygroup";
var markers = OnlineMaps.instance.markers.Where(delegate(OnlineMapsMarker marker)
{
    // It does not matter what CData class is here. 
    // You can store any object in customData.
    CData data = marker.customData as CData;
    return data != null && data.group == groupID;
});
foreach (OnlineMapsMarker marker in markers)
{
    // do something
}
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: How to modify a certain group 2D of markers?

Thank you, Alex Vertax, for very interesting examples...
Talking about the LINQ example - this way we can iterate through the array of markers and "do something" with markers with a specific tag, right?

1) How can I assign a tag to a marker (probably we should somehow do it during its creation via OnlineMaps.AddMarker)?
2) Is there a way to "disable" and "enable" 2D markers? Or we should remove/create them instead?
3)How can I pass the markers (which I can select using the LINQ example) to the OnlineMaps.RemoveMarker() function in order to remove them?

Thank you!

Re: How to modify a certain group 2D of markers?

The first example for markers with a tag.
The second example for markers with information in customData.

1. Example:

OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(lng, lat);
marker.tags.Add("mytag");

2. OnlineMapsMarkerBase.enabled.
Example:

OnlineMapsMarker marker = OnlineMaps.instance.AddMarker(lng, lat);
marker.enabled = false;

3. If you want to remove the markers that have the specified tag, use OnlineMaps.RemoveMarkersByTag.
You have direct access to the array of markers, so you can implement the rule of removing markers of any complexity.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.