<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Clustering 3D Markers]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=394</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=394&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Clustering 3D Markers.]]></description>
		<lastBuildDate>Tue, 31 Jan 2017 12:41:58 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1756#p1756</link>
			<description><![CDATA[<p>Group3DMarkers.GroupMarkers:<br /></p><div class="codebox"><pre><code>for (int zoom = OnlineMaps.MAXZOOM - 1; zoom &gt;= 3; zoom--)</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Tue, 31 Jan 2017 12:41:58 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1756#p1756</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1755#p1755</link>
			<description><![CDATA[<p>It correctly clusters at far zoomed out levels now <img src="https://forum.infinity-code.com/img/smilies/smile.png" width="15" height="15" alt="smile" /> But some remain clustered even at zoom level 20 (the most zoomed in).</p>]]></description>
			<author><![CDATA[null@example.com (alexandra)]]></author>
			<pubDate>Tue, 31 Jan 2017 10:07:50 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1755#p1755</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1748#p1748</link>
			<description><![CDATA[<p>I found the problem:<br />GetData.cs: 86<br />marker3D.range = new OnlineMapsRange (1, 20);</p><p>You can fix this in three ways:<br />1. Just comment out this line.<br />2. Use OnlineMapsRange (3, 20);<br />3. In Group3DMarkers: 56, 59, replace «range.min == 3» to «range.min == 1».</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 30 Jan 2017 12:50:02 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1748#p1748</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1747#p1747</link>
			<description><![CDATA[<p>We already do that, after all markers are created, &quot;StartGrouping()&quot; from Group3DMarkers is called.</p><p>foreach (var o in obj.response_details)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[...]<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CreateMarker(o);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; OnlineMaps.instance.GetComponent&lt;Group3DMarkers&gt;().StartGrouping();</p><p>-------<br /> public void StartGrouping()<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; markers.AddRange(OnlineMapsControlBase3D.instance.markers3D);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; GroupMarkers();<br />&nbsp; &nbsp; }</p>]]></description>
			<author><![CDATA[null@example.com (alexandra)]]></author>
			<pubDate>Mon, 30 Jan 2017 10:32:47 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1747#p1747</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1746#p1746</link>
			<description><![CDATA[<p>The problem is that the markers are grouped in Start.<br />You need to make the method «public static void GroupMarkers()», and invoke it after creating of markers.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 27 Jan 2017 19:56:02 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1746#p1746</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1744#p1744</link>
			<description><![CDATA[<p>I tried a few distances between 99999 and 0.00001 and nothing seemed to change. I&#039;ve send you the unity scene through PM.</p>]]></description>
			<author><![CDATA[null@example.com (alexandra)]]></author>
			<pubDate>Fri, 27 Jan 2017 09:11:49 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1744#p1744</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1742#p1742</link>
			<description><![CDATA[<p>Try to increase the distance.<br />If the problem persists, please send us the scene (as package) where you have a problem. We will check it.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Thu, 26 Jan 2017 20:38:46 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1742#p1742</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1739#p1739</link>
			<description><![CDATA[<p>I&#039;m still having a few issues.<br />It&#039;s not clustering all the markers it should be as can be seen when zoomed out more, and it doesn&#039;t always decluster markers, even on zoomlevel 20 (which is het closest zoomlevel).<br />In these photos the regular white circles are the clusters (not really noticeable I know hehe..).</p>]]></description>
			<author><![CDATA[null@example.com (alexandra)]]></author>
			<pubDate>Thu, 26 Jan 2017 12:09:56 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1739#p1739</guid>
		</item>
		<item>
			<title><![CDATA[Re: Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1712#p1712</link>
			<description><![CDATA[<p>Hello.</p><p>Example of clustering 3D Markers:<br /></p><div class="codebox"><pre><code>using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class Group3DMarkers:MonoBehaviour
{
    public GameObject prefab;
    public GameObject groupPrefab;

    public int countMarkers = 100;
    public float distance = 30f / OnlineMapsUtils.tileSize; // pixels / 256

    private List&lt;OnlineMapsMarker3D&gt; markers;

    private void Start()
    {
        markers = new List&lt;OnlineMapsMarker3D&gt;();

        for (int i = 0; i &lt; countMarkers; i++)
        {
            OnlineMapsMarker3D marker = OnlineMapsControlBase3D.instance.AddMarker3D(new Vector2(Random.Range(-180f, 180f), Random.Range(-80, 80)), prefab);
            marker.label = &quot;Marker &quot; + i;
            markers.Add(marker);
        }

        GroupMarkers();
    }

    private void GroupMarkers()
    {
        List&lt;MarkerGroup&gt; groups = new List&lt;MarkerGroup&gt;();
        float sqrDist = distance * distance;
        OnlineMaps map = OnlineMaps.instance;

        for (int zoom = OnlineMaps.MAXZOOM; zoom &gt;= 3; zoom--)
        {
            List&lt;OnlineMapsMarker3D&gt; ms = markers.ToList();

            for (int j = 0; j &lt; ms.Count - 1; j++)
            {
                OnlineMapsMarker3D marker = ms[j];
                MarkerGroup group = null;
                double px, py;
                marker.GetPosition(out px, out py);
                map.projection.CoordinatesToTile(px, py, zoom, out px, out py);

                int k = j + 1;

                while (k &lt; ms.Count)
                {
                    OnlineMapsMarker3D marker2 = ms[k];

                    double p2x, p2y;
                    marker2.GetPosition(out p2x, out p2y);
                    map.projection.CoordinatesToTile(p2x, p2y, zoom, out p2x, out p2y);

                    if (OnlineMapsUtils.SqrMagnitude(px, py, p2x, p2y) &lt; sqrDist)
                    {
                        if (group == null)
                        {
                            group = new MarkerGroup(zoom, groupPrefab);
                            groups.Add(group);
                            group.Add(marker);
                            if (marker.range.min == 3) marker.range.min = zoom + 1;
                        }
                        group.Add(marker2);
                        if (marker2.range.min == 3) marker2.range.min = zoom + 1;
                        ms.RemoveAt(k);
                        px = group.tilePositionX;
                        py = group.tilePositionY;
                    }
                    else k++;
                }
            }
        }
    }

    internal class MarkerGroup
    {
        public readonly List&lt;OnlineMapsMarker3D&gt; markers;
        public readonly OnlineMapsMarker3D instance;

        public Vector2 center;
        public double tilePositionX, tilePositionY;

        public int zoom;

        public MarkerGroup(int zoom, GameObject prefab)
        {
            markers = new List&lt;OnlineMapsMarker3D&gt;();
            this.zoom = zoom;
            instance = OnlineMapsControlBase3D.instance.AddMarker3D(Vector2.zero, prefab);
            instance.range = new OnlineMapsRange(zoom, zoom);
        }

        public void Add(OnlineMapsMarker3D marker)
        {
            markers.Add(marker);
            center = markers.Aggregate(Vector2.zero, (current, m) =&gt; current + m.position) / markers.Count;
            instance.position = center;
            OnlineMaps.instance.projection.CoordinatesToTile(center.x, center.y, zoom, out tilePositionX, out tilePositionY);
            instance.label = &quot;Group. Count: &quot; + markers.Count;
        }
    }
}</code></pre></div><p>However, clustering does not help solve the problem of a large number of markers.<br />For each marker (even inactive) made a some number of operations in each frame.<br />To have a great performance, you need to help map and reduce the number of markers.<br />For example:<br /><a href="http://forum.infinity-code.com/viewtopic.php?pid=650#p650">http://forum.infinity-code.com/viewtopi … d=650#p650</a></p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Mon, 23 Jan 2017 22:52:33 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1712#p1712</guid>
		</item>
		<item>
			<title><![CDATA[Clustering 3D Markers]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1706#p1706</link>
			<description><![CDATA[<p>Hi!<br />We have a LOT of markers to show in certain areas and it makes our program ridiculously slow. So we are looking into a way to cluster markers like here:<br /><a href="https://developers.google.com/maps/documentation/javascript/marker-clustering">https://developers.google.com/maps/docu … clustering</a></p><p>We saw a demo script for this in the Atlas (<a href="http://infinity-code.com/atlas/online-maps/pages/GroupMarkersExample.html">http://infinity-code.com/atlas/online-m … ample.html</a>), but we couldn&#039;t get this to work correctly. When we zoomed in on the cluster image it never broke down in separate markers, and the separate markers close together never became clusters.<br />Also this example is for 2D markers and we use 3D markers. Is it possible to do clustering of 3D markers?</p>]]></description>
			<author><![CDATA[null@example.com (alexandra)]]></author>
			<pubDate>Mon, 23 Jan 2017 13:35:50 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1706#p1706</guid>
		</item>
	</channel>
</rss>
