Re: A way to implement clustering?

Thanks! will try it

Re: A way to implement clustering?

Hello,

I am attaching a small script (PlayerData) to the markers I am generating, and I am filling values in that script, so when I click on the marker I can get values from this script regarding the marker/player I tapped but these values reset as soon as i zoom out and then back in (clustered to un-clustered) if you want I can post my code here as well.

Re: A way to implement clustering?

Yes, please post your script.

Kind Regards,
Infinity Code Team.

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

Re: A way to implement clustering?

Attaching the screencap of the issue here along with the code :

Link to screen cap : https://www.dropbox.com/s/vczk55yk36t63 … s.mp4?dl=0

    void CreateMarkers ()
    {

        for (int i = 0; i < PSD.Count; i++) {
            try{
            var playerObject = PSD [i];

            int TempLP = UnityEngine.Random.Range (-7, 7);
            OnlineMapsMarker3D player = new OnlineMapsMarker3D();
            Vector2 pos = new Vector2(playerObject.longitude,playerObject.latitude);

            if (playerObject.gender == "male") {
                if ( TempLP > 0)
                        player = control.AddMarker3D(pos,WhiteMale);
                else if (TempLP  == 0)
                        player = control.AddMarker3D(pos,GreyMale);
                else
                        player = control.AddMarker3D(pos,shadowMale);
            } else {
                if (TempLP  > 0)
                        player = control.AddMarker3D(pos,WhiteFemale);
                else if (TempLP  == 0)
                        player = control.AddMarker3D(pos,GreyFemale);
                else
                        player = control.AddMarker3D(pos,ShadowFemale);
            }

                print(playerObject.PlayerName);
     
            player.scale = playerIconScale;
            var pData = player.instance.GetComponent<playerData> ();  
            pData.playerName = playerObject.PlayerName;
            pData.lunarPhase = TempLP; 
            pData.gender = playerObject.gender;
            pData.latitude = playerObject.latitude;
            pData.longitude = playerObject.longitude;
            pData.bot = true;
                

            Clustering3DMarkers.Add(player);
            markers.Add (player); 
            }catch (Exception e) {
                Debug.LogError (e);
            }

    }

Re: A way to implement clustering?

I watched your video several times, but unfortunately, I did not understood what is wrong.
You wrote that it resets the values when zoom out.
I did not see this in the video.

Please explain in more detail what I should see in the script and / or video.

Kind Regards,
Infinity Code Team.

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

Re: A way to implement clustering?

As you can see I am assigning names which I fetch from our database in the "PlayerData" script attached to the markers.

   pData.playerName = playerObject.PlayerName; 

I am also printing the name before I assign it to the console

  print(playerObject.PlayerName); 

And on the console you can see all the unique names which are displayed, but on the map you can see the repeating names, I am displaying these names on top of players inside textboxes, which have a OnEnable function to read these values from the playerData script's playername string variable. These names are repeating which should not happen as all the names are unique and do not repeat.

When I check the markers under the tileset object I can see that a few of the markers have repeating names in the playerdata component.

Hope this made sense, if not I can re record the screen capture and narrate on top of it so it makes more sense.

Thansk.

Re: A way to implement clustering?

The problem is that OnEnable works before you set a new value.

Example:

using UnityEngine;

public class TestOnEnable:MonoBehaviour
{
    private void Awake()
    {
        Debug.Log("Awake");
    }

    private void OnEnable()
    {
        Debug.Log("OnEnable");
    }

    private void Start()
    {
        Debug.Log("Start");
    }
}

public class TestOnEnable2:MonoBehaviour
{
    public GameObject prefab;

    private void Start()
    {
        Debug.Log("Before creation");
        OnlineMapsControlBase3D.instance.AddMarker3D(OnlineMaps.instance.position, prefab);
        Debug.Log("After creation");
    }
}

Result:
Before creation
Awake
OnEnable
OnEnable
After creation
Start

Kind Regards,
Infinity Code Team.

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

Re: A way to implement clustering?

Thanks I just ended up storing values in custom data parameter of the marker works good now, and yea that's what I was doing wrong.
So after you play the game for a couple of minute - zoom/pan around the map this starts to happen, I am not sure what I should attach here to help you debug this easily.
Detached markers : https://www.dropbox.com/s/3krwy4x6zgleh … r.mp4?dl=0

Re: A way to implement clustering?

Something's wrong with your link.
Try to post the link again.

Kind Regards,
Infinity Code Team.

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

Re: A way to implement clustering?

https://www.dropbox.com/s/3krwy4x6zgleh … r.mp4?dl=0

Re: A way to implement clustering?

First of all, check the console. Perhaps you have any error messages.

Honestly, it's very difficult to say why some GameObjects are not destroyed correctly.
The problem can be on your side, in a clustering script, or in Online Maps.
This can only be known by debugging a project where the problem is appears.

Kind Regards,
Infinity Code Team.

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

37 (edited by Mridul 2017-06-23 23:11:57)

Re: A way to implement clustering?

I have been looking at the console, I dont see any errors, I will attach some more try catch statements just to be sure I dont miss any error, could you point me in the direction as of what I should be looking when this happens? or atleast a way to narrow the problem and its cause?

Or atleast maybe a way to find these markers and destroy them after wards?, If I can isolate just these markers i can Destroy them during on OnChangePosition.

Thanks

Re: A way to implement clustering?

This occurs when 3D marker has been removed, but GameObject remains.
Usually this is either an error or an exception.
Find these 3D markers is very easy: pause the scene, open the scene view, and click on marker.

Kind Regards,
Infinity Code Team.

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

Re: A way to implement clustering?

Okay, thanks I will take a look into it. I have actually clicked on these markers, as you say that the marker is destroyed but the gameobject remains, however these markerObjects still have onlinemapmarker3Dinstance script attached to them, should that be removed if the marker is destroyed or it can still be there?

40 (edited by zuicis 2017-06-26 06:04:18)

Re: A way to implement clustering?

If you remove 3D marker, then marker GO automaticly removes, if you remove marker GO, then 3D marker stays and on next refresh automaticly creates new marker GO without data (if you attached your script). Don't destroy marker GO without removing 3D marker from OnlineMapsTileSetControl list.

Re: A way to implement clustering?

I am actually doing that, I do not destroy gameObject directly, I first call ClusterMarker3D.RemoveUnclustered() and then TileSetControl.Remove();

42 (edited by zuicis 2017-07-30 08:39:49)

Re: A way to implement clustering?

Found bug at this script.

a) After map drag on big distances (from map center and then back) pravious generated markers are visible if mapView false

Update, solution: disable all prefab gameObjects for markiers/clusters in unity or in start() (my fault, i have them enabled)


b) markers lose they rotation info after map rotation + drag on big distances.

Ugly solution:
public static float mAngle = -40;  //def marker angle. (auto changes if we change map angle on zoom+SkyBox+farClipPlane )

public static void UpdateMarkers()
    {
          --- orginal code ---

            if (!isExist){
                OnlineMapsUtils.DestroyImmediate(m.instance);
                m.instance = null;
            }else{
                m.rotation = Quaternion.Euler(mAngle, OnlineMapsTileSetControl.instance.cameraRotation.y, 0f);                 
            }

        --- orginal code ---
    }