<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — A way to implement clustering?]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=377&amp;type=atom" />
	<updated>2017-07-19T05:40:22Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=377</id>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2625#p2625" />
			<content type="html"><![CDATA[<p>Found bug at this script. </p><p>a) After map drag on big distances (from map center and then back) pravious generated markers are visible if mapView false</p><p>Update, solution: disable all prefab gameObjects for markiers/clusters in unity or in start() (my fault, i have them enabled)</p><br /><p>b) markers lose they rotation info after map rotation + drag on big distances.</p><p>Ugly solution:<br />public static float mAngle = -40;&nbsp; //def marker angle. (auto changes if we change map angle on zoom+SkyBox+farClipPlane )</p><p>public static void UpdateMarkers()<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --- orginal code ---</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!isExist){<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OnlineMapsUtils.DestroyImmediate(m.instance);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m.instance = null;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }else{<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; m.rotation = Quaternion.Euler(mAngle, OnlineMapsTileSetControl.instance.cameraRotation.y, 0f);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; --- orginal code ---<br />&nbsp; &nbsp; }</p>]]></content>
			<author>
				<name><![CDATA[zuicis]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=67</uri>
			</author>
			<updated>2017-07-19T05:40:22Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2625#p2625</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2536#p2536" />
			<content type="html"><![CDATA[<p>I am actually doing that, I do not destroy gameObject directly, I first call ClusterMarker3D.RemoveUnclustered() and then TileSetControl.Remove();</p>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-26T06:14:40Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2536#p2536</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2535#p2535" />
			<content type="html"><![CDATA[<p>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&#039;t destroy marker GO without removing 3D marker from OnlineMapsTileSetControl list.</p>]]></content>
			<author>
				<name><![CDATA[zuicis]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=67</uri>
			</author>
			<updated>2017-06-26T05:51:32Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2535#p2535</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2521#p2521" />
			<content type="html"><![CDATA[<p>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?</p>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-23T23:35:57Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2521#p2521</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2520#p2520" />
			<content type="html"><![CDATA[<p>This occurs when 3D marker has been removed, but GameObject remains.<br />Usually this is either an error or an exception.<br />Find these 3D markers is very easy: pause the scene, open the scene view, and click on marker.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-06-23T23:22:36Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2520#p2520</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2519#p2519" />
			<content type="html"><![CDATA[<p>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?</p><p>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.</p><p>Thanks</p>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-23T23:10:17Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2519#p2519</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2517#p2517" />
			<content type="html"><![CDATA[<p>First of all, check the console. Perhaps you have any error messages.</p><p>Honestly, it&#039;s very difficult to say why some GameObjects are not destroyed correctly. <br />The problem can be on your side, in a clustering script, or in Online Maps.<br />This can only be known by debugging a project where the problem is appears.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-06-23T22:46:14Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2517#p2517</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2515#p2515" />
			<content type="html"><![CDATA[<p><a href="https://www.dropbox.com/s/3krwy4x6zgleh72/FlyingMarker.mp4?dl=0">https://www.dropbox.com/s/3krwy4x6zgleh … r.mp4?dl=0</a></p>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-23T00:57:40Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2515#p2515</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2514#p2514" />
			<content type="html"><![CDATA[<p>Something&#039;s wrong with your link.<br />Try to post the link again.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-06-23T00:21:19Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2514#p2514</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2513#p2513" />
			<content type="html"><![CDATA[<p>Thanks I just ended up storing values in custom data parameter of the marker works good now, and yea that&#039;s what I was doing wrong.<br />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.<br />Detached markers : <a href="https://www.dropbox.com/s/3krwy4x6zgleh">https://www.dropbox.com/s/3krwy4x6zgleh</a> … r.mp4?dl=0</p>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-22T22:47:47Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2513#p2513</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2505#p2505" />
			<content type="html"><![CDATA[<p>The problem is that OnEnable works before you set a new value.</p><p>Example:<br /></p><div class="codebox"><pre><code>using UnityEngine;

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

    private void OnEnable()
    {
        Debug.Log(&quot;OnEnable&quot;);
    }

    private void Start()
    {
        Debug.Log(&quot;Start&quot;);
    }
}

public class TestOnEnable2:MonoBehaviour
{
    public GameObject prefab;

    private void Start()
    {
        Debug.Log(&quot;Before creation&quot;);
        OnlineMapsControlBase3D.instance.AddMarker3D(OnlineMaps.instance.position, prefab);
        Debug.Log(&quot;After creation&quot;);
    }
}</code></pre></div><p>Result:<br />Before creation<br />Awake<br />OnEnable<br />OnEnable<br />After creation<br />Start</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-06-21T15:28:52Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2505#p2505</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2504#p2504" />
			<content type="html"><![CDATA[<p>As you can see I am assigning names which I fetch from our database in the &quot;PlayerData&quot; script attached to the markers. <br /></p><div class="codebox"><pre><code>   pData.playerName = playerObject.PlayerName; </code></pre></div><p>I am also printing the name before I assign it to the console<br /></p><div class="codebox"><pre><code>  print(playerObject.PlayerName); </code></pre></div><p>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&#039;s playername string variable. These names are repeating which should not happen as all the names are unique and do not repeat.</p><p>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. </p><p>Hope this made sense, if not I can re record the screen capture and narrate on top of it so it makes more sense.</p><p>Thansk.</p>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-21T15:09:35Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2504#p2504</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2503#p2503" />
			<content type="html"><![CDATA[<p>I watched your video several times, but unfortunately, I did not understood what is wrong.<br />You wrote that it resets the values when zoom out.<br />I did not see this in the video.</p><p>Please explain in more detail what I should see in the script and / or video.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-06-21T14:59:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2503#p2503</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2502#p2502" />
			<content type="html"><![CDATA[<p>Attaching the screencap of the issue here along with the code :</p><p>Link to screen cap : <a href="https://www.dropbox.com/s/vczk55yk36t635e/cluster%20marker%20icons.mp4?dl=0">https://www.dropbox.com/s/vczk55yk36t63 … s.mp4?dl=0</a></p><div class="codebox"><pre><code>    void CreateMarkers ()
    {

        for (int i = 0; i &lt; 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 == &quot;male&quot;) {
                if ( TempLP &gt; 0)
                        player = control.AddMarker3D(pos,WhiteMale);
                else if (TempLP  == 0)
                        player = control.AddMarker3D(pos,GreyMale);
                else
                        player = control.AddMarker3D(pos,shadowMale);
            } else {
                if (TempLP  &gt; 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&lt;playerData&gt; ();  
            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);
            }

    }</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Mridul]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=225</uri>
			</author>
			<updated>2017-06-21T14:39:38Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2502#p2502</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: A way to implement clustering?]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=2500#p2500" />
			<content type="html"><![CDATA[<p>Yes, please post your script.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2017-06-20T09:08:31Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=2500#p2500</id>
		</entry>
</feed>
