Topic: Marker position

Hi,

   I use this code to set many PIN markers (blue in the image) on a map ant then just one POI (the green one):

...
               // Set PIN on map
        for (int i=0; i<PINName.Count; i++) {
            PINPos.x = float.Parse(PINLon[\i].ToString ());
            PINPos.y = float.Parse(PINLat[\i].ToString ());
            MapLocation = PINName[\i].ToString ();
            OnlineMaps.instance.AddMarker (PINPos, PINTexture, MapLocation);
        }

        // Set POI on map
        PINPos = new Vector2 (MapLon, MapLat);
        OnlineMaps.instance.zoom = 9;
        OnlineMaps.instance.SetPosition (MapLon, MapLat);
        OnlineMaps.instance.AddMarker (PINPos, MapLocation);
...

There is a way to place la last marker (the green one), in front of the others?
Now his position seems random: somethimes is in front, sometimes is behind other markers.

Thank you!

Re: Marker position

Hello.

Your post does not contain any image.

For tileset:
OnlineMapsTileSetControl.markerComparer
Example:
http://infinity-code.com/atlas/online-m … ample.html

For others:
OnlineMapsBuffer.OnSortMarker
Unfortunately, we do not have an example for this.
If you need an example, just tell me and I'll do it.

Kind Regards,
Infinity Code Team.

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

Re: Marker position

Thank you Alex; the image is attached now.

I need to place the last marker (named POI in code below and green in imange), in front of other markers (the blue one), possibly with his label open.

Thanks!

Post's attachments

Attachment icon map.png 77.44 kb, 259 downloads since 2017-02-18 

Re: Marker position

For example in this way:

using UnityEngine;
using Random = UnityEngine.Random;

public class ShowPlayerMarkerOnFront:MonoBehaviour
{
    public int countMarkers = 100;
    public Texture2D playerTexture;

    private Renderer markersRenderer;

    private void Start()
    {
        GenerateMarkers();
        OnlineMapsTileSetControl.instance.OnMeshUpdated += OnMeshUpdated;
    }

    private void OnMeshUpdated()
    {
        if (markersRenderer == null)
        {
            Transform markersTransform = OnlineMaps.instance.transform.FindChild("Markers");
            if (markersTransform == null) return;
            markersRenderer = markersTransform.GetComponent<Renderer>();
        }

        Material[] materials = markersRenderer.sharedMaterials;
        for (int i = 0; i < materials.Length; i++)
        {
            Material material = materials[i];
            material.renderQueue = material.shader.renderQueue;
            if (material.mainTexture == playerTexture) material.renderQueue += 1;
        }
    }

    private void GenerateMarkers()
    {
        double tlx, tly, brx, bry;
        OnlineMaps map = OnlineMaps.instance;
        map.GetCorners(out tlx, out tly, out brx, out bry);

        for (int i = 0; i < countMarkers; i++)
        {
            float lng = Random.Range((float)tlx, (float)brx);
            float lat = Random.Range((float)bry, (float)tly);

            map.AddMarker(lng, lat);
        }

        map.AddMarker(map.position, playerTexture, "Player");
    }
}
Kind Regards,
Infinity Code Team.

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