<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bojan Kovačec on Medium]]></title>
        <description><![CDATA[Stories by Bojan Kovačec on Medium]]></description>
        <link>https://medium.com/@bojan.kovacec?source=rss-800ddd5ef50------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oMwsFajKVA2ngRVi.</url>
            <title>Stories by Bojan Kovačec on Medium</title>
            <link>https://medium.com/@bojan.kovacec?source=rss-800ddd5ef50------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:48:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bojan.kovacec/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Location markers grouping]]></title>
            <link>https://medium.com/@bojan.kovacec/location-markers-grouping-7f70384f0bfb?source=rss-800ddd5ef50------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f70384f0bfb</guid>
            <category><![CDATA[google-maps]]></category>
            <dc:creator><![CDATA[Bojan Kovačec]]></dc:creator>
            <pubDate>Tue, 14 Apr 2020 15:36:03 GMT</pubDate>
            <atom:updated>2020-04-14T15:36:03.592Z</atom:updated>
            <content:encoded><![CDATA[<p>With presentation of locations on screen we are limited with resolution.</p><p>Image 1: to many markers</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNU-3FVoDtncuTRy4gGUNQ.png" /><figcaption>random seeding of locations</figcaption></figure><h3>Grouping</h3><p>To improve visibility we group markers with information about number of locations in certain area.</p><h4>Grouping by squares</h4><p>We split length and width of surface to <em>n </em>equal areas. We get <em>n</em>² equal surfaces and count number of position on each.</p><p><em>length = most east location — most west location<br>height = most south location — most north location</em></p><p><em>i = [0 … n -1]<br>x(i) = west + length / n * i<br>y(i) = south + height / n * i</em></p><p>Example: <em>n = 3</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unGN0rI8WATCrwYvH608-Q.jpeg" /></figure><h3>Database queries</h3><h4>Entity — relationship database</h4><p>Let for example say we have table <em>items</em> with columns <em>latitude</em> and <em>longitude</em> with real numbers.</p><pre><strong>select </strong><em>count</em>(*) <strong>as count</strong>,<br>  <strong>CASE<br>    WHEN </strong>latitude <strong>BETWEEN x[0] and x[1] <br>      AND </strong>longitude <strong>BETWEEN y[0] and y[0] THEN 0</strong><br>    <strong>WHEN </strong>latitude <strong>BETWEEN x[1] and x[2] <br>      AND </strong>longitude <strong>BETWEEN y[1] and y[2] THEN </strong>1<br>    ...<br>  <strong>END as </strong>intervals<br><strong>FROM </strong><em>items</em><br>  <strong>WHERE </strong>latitude &gt; x[0] <strong>and </strong>latitude &lt; x[n]<br>        <strong>and </strong>longitude &gt; y[0] <strong>and </strong>longitude &lt; y[n]<br><strong>GROUP BY </strong>intervals;</pre><h3>json</h3><p>For serverless website it is more appropriate that we store data in json and the client parse if for view on the map. If we have bigger data we could build a search tree but lets start with linear search and test performance.</p><p>Example of locations.</p><pre>[<br>  {<br>    &quot;lat&quot;: &quot;50.80228554&quot;,<br>    &quot;lng&quot;: &quot;11.10132815&quot;,<br>    &quot;ttl&quot;: &quot;test title0&quot;<br>  },<br>  {<br>    &quot;lat&quot;: &quot;50.40709154&quot;,<br>    &quot;lng&quot;: &quot;11.79868412&quot;,<br>    &quot;ttl&quot;: &quot;test title1&quot;<br>  },<br><br>  ...</pre><pre>]</pre><p>… and then I found solution from <a href="https://docs.mapbox.com/mapbox-gl-js/example/cluster/">https://docs.mapbox.com/mapbox-gl-js/example/cluster/</a> which works great.</p><h3>Demo with Google Maps</h3><p><a href="http://ecom.locate.tips/near">ecom</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f70384f0bfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>