<?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 — How to draw a circle on the map?!]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=232</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=232&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in How to draw a circle on the map?!.]]></description>
		<lastBuildDate>Fri, 17 Mar 2023 19:46:27 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8908#p8908</link>
			<description><![CDATA[<p>Post #6 explains how to scale 2D markers.<br />But I would use 3D markers. At least because it has the inbuilt ability to have the size in metres.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 17 Mar 2023 19:46:27 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8908#p8908</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8907#p8907</link>
			<description><![CDATA[<p>Well before you replied, i already checked the 2dtexture marker, but issue is i want to draw that circle on a specific radius. like the drawing circle functionality do, <br />I want my custom circle to be drawed to the whole radius. when i zoom the map, that marker is also zoomed. And in drawed circle functionality, the circle is not zoomed. It is still there where the boundaries are.</p>]]></description>
			<author><![CDATA[null@example.com (uneebkari)]]></author>
			<pubDate>Fri, 17 Mar 2023 19:38:40 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8907#p8907</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8906#p8906</link>
			<description><![CDATA[<p>Hello.</p><p>For the way in post #2 to have filling see documentation (Troubleshooting / Known Issues section).</p><p>Or use the way in post #6.</p><p>Or you can use a 3D marker with a circle prefab.</p><p>Or you can use TilesetOverlayExample (see example atlas), where the overlay will contain a circle texture.</p><p>Or you can write a custom map shader that will draw circles. It&#039;s not very complicated, but you will be able to have a limited number of circles.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 17 Mar 2023 18:49:11 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8906#p8906</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=8905#p8905</link>
			<description><![CDATA[<p>Hi<br />I check your circle drawing, it just draws a bordered circle, what am i look is draw a custom circle with a center filler with 40% opacity and thick border.<br />Can anyone please help me in drawing such circle.</p>]]></description>
			<author><![CDATA[null@example.com (uneebkari)]]></author>
			<pubDate>Fri, 17 Mar 2023 13:24:07 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=8905#p8905</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1055#p1055</link>
			<description><![CDATA[<p>That explains it. Thanks!</p>]]></description>
			<author><![CDATA[null@example.com (kalaki)]]></author>
			<pubDate>Fri, 05 Aug 2016 18:14:52 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1055#p1055</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1054#p1054</link>
			<description><![CDATA[<p>Because these methods has been added in Online Maps v2.4.<br />For Online Maps v2.3 use OnlineMapsUtils.LatLongToTiled, OnlineMapsUtils.TileToLatLong, OnlineMapsMarkerBase.position.<br />Or just update Online Maps through the built-in update system.</p><p>How to open the built-in update system:<br />Online Maps / Help / Check Updates.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 05 Aug 2016 17:16:46 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1054#p1054</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1052#p1052</link>
			<description><![CDATA[<p>This is probably a silly question but when I try use the code in post #2 I get errors:<br />OnlineMapsProjection&nbsp; &lt;-- class is missing<br />OnlineMapsMarker.GetPosition&nbsp; &lt;-- GetPoistion is missing <br />OnlineMaps.projection&nbsp; &lt;-- projection is missing</p><p>OnlineMaps.version == &quot;2.3.0.18&quot;</p>]]></description>
			<author><![CDATA[null@example.com (kalaki)]]></author>
			<pubDate>Fri, 05 Aug 2016 15:50:06 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1052#p1052</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1051#p1051</link>
			<description><![CDATA[<p>Thanks for the tip, you are absolutely correct!</p>]]></description>
			<author><![CDATA[null@example.com (SweetTooth)]]></author>
			<pubDate>Fri, 05 Aug 2016 14:01:10 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1051#p1051</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1050#p1050</link>
			<description><![CDATA[<p>Actually better to use OnChangePosition and OnChangeZoom, to reduce the number of calculations and do not position GameObject each frame.<br />This example is quite old, and I do not remember why I used Update.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 05 Aug 2016 13:03:37 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1050#p1050</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1049#p1049</link>
			<description><![CDATA[<p>Actually you are absolutely right, the circle mesh solution is just perfect! Although I should note that if you include it into API examples, please replace Update method with the LateUpdate, so that there would be no visible delay when the map is being scrolled.</p><p>And thank you very much for the distance limitation example, that&#039;s just what we need!</p>]]></description>
			<author><![CDATA[null@example.com (SweetTooth)]]></author>
			<pubDate>Fri, 05 Aug 2016 12:54:39 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1049#p1049</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1048#p1048</link>
			<description><![CDATA[<p>Both solutions (post 2, 6) reach your goals.<br />Please explain more detail why you can not use it?</p><p>Example how to limit the distance of the map from the marker:<br /></p><div class="codebox"><pre><code>using System;
using UnityEngine;

public class LimitPositionWithRadius:MonoBehaviour
{
    public float raduis = 1.5f; // km
    private OnlineMapsMarker playerMarker;
    private float sqrRadius;
    private OnlineMaps map;
    private bool ignoreEvent;

    private void Start()
    {
        sqrRadius = raduis * raduis;
        map = OnlineMaps.instance;
        map.OnChangePosition += OnChangePosition;
        map.OnChangeZoom += OnChangePosition;
        playerMarker = map.AddMarker(map.position, &quot;Player&quot;);
    }

    private void OnChangePosition()
    {
        if (ignoreEvent) return;

        double mx, my;
        playerMarker.GetPosition(out mx, out my);

        double px, py;
        map.GetPosition(out px, out py);

        double dx, dy;
        OnlineMapsUtils.DistanceBetweenPoints(px, py, mx, my, out dx, out dy);
        double sqrR = dx * dx + dy * dy;
        if (sqrR &gt; sqrRadius)
        {
            double tx1, ty1, tx2, ty2;
            map.projection.CoordinatesToTile(px, py, map.zoom, out tx1, out ty1);
            map.projection.CoordinatesToTile(mx, my, map.zoom, out tx2, out ty2);

            double scale = raduis / Math.Sqrt(sqrR);
            double ntx = tx2 + (tx1 - tx2) * scale;
            double nty = ty2 + (ty1 - ty2) * scale;
            map.projection.TileToCoordinates(ntx, nty, map.zoom, out ntx, out nty);
            ignoreEvent = true;
            map.SetPosition(ntx, nty);
            ignoreEvent = false;

            OnlineMapsUtils.DistanceBetweenPoints(ntx, nty, mx, my, out dx, out dy);
            Debug.Log(&quot;New distance: &quot; + Math.Sqrt(dx * dx + dy * dy));
        }
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 05 Aug 2016 12:38:22 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1048#p1048</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1044#p1044</link>
			<description><![CDATA[<p>I&#039;m very sorry for so many questions, pleae bear with me...</p><p>Actually I also need to limit, how far the map can be scrolled - for example, no further than 1.5 kilometers from current player position... And it seems that in order to do this (in order to calculate OnlineMapsPositionRange), I have to basically solve the same problem - to find points in (lat, long), which would have a distance of 1500 meters between them and a player position. Can you please tell me, how can I do this?</p>]]></description>
			<author><![CDATA[null@example.com (SweetTooth)]]></author>
			<pubDate>Fri, 05 Aug 2016 11:34:48 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1044#p1044</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1043#p1043</link>
			<description><![CDATA[<p>Thank you very much, Alex!</p><p>I&#039;m sorry for any confusion I caused... You see, we have objects (markers) on the map and want to show a circle around player marker, which should explain to player which objects can be interacted with (since they are considered visible) and which can&#039;t (the player should reach them first)... So on the one hand we need a solution, which would look physically correct (the circle should overlap the visible markers and match the distance to objects, which is also being displayed) and on the other hand everything should scale like markers when zoom level is changed...</p><p>Can you please help us understand, how to do this?</p>]]></description>
			<author><![CDATA[null@example.com (SweetTooth)]]></author>
			<pubDate>Fri, 05 Aug 2016 11:25:19 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1043#p1043</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1042#p1042</link>
			<description><![CDATA[<p>To make a circle more accurate increase segments.</p><p>Yes, you can place the mesh on the map.<br />Actually, it would be a much better solution.<br />The example below.<br />Just your original question was about poly.<br />Use OnlineMapsTileSetControl.GetWorldPosition, to convert coordinates in Unity World Space position.<br /><a href="http://infinity-code.com/doxygen/online-maps/classOnlineMapsTileSetControl.html#adcfdea4962fd10c64683602992c6e097">http://infinity-code.com/doxygen/online … 2992c6e097</a></p><p>Yes, you can convert the radius in meters to pixels.<br />If you really need it, I can give an example.<br />But keep in mind a few things:<br />1. The radius in pixels (R) is different at different zoom level.<br />2. R is different at different latitudes.<br />3. R left == R right.<br />4. R left != R up.<br />5. R up != R down.</p><p>Example of drawing a circle using mesh:<br /></p><div class="codebox"><pre><code>using UnityEngine;

public class DrawCircleWithRadius : MonoBehaviour
{
    public GameObject circle;
    public float diameterInKM = 0.5f;
    public float sizeY = 0.02f;

    private OnlineMapsMarker marker;

    private void Start()
    {
        marker = OnlineMaps.instance.AddMarker(OnlineMaps.instance.position, &quot;Marker&quot;);
    }

    private void Update ()
    {
        circle.transform.position = OnlineMapsTileSetControl.instance.GetWorldPosition(marker.position);

        OnlineMaps api = OnlineMaps.instance;

        Vector2 distance = OnlineMapsUtils.DistanceBetweenPoints(api.topLeftPosition, api.bottomRightPosition);

        float scaleX = diameterInKM / distance.x * api.tilesetSize.x;
        float scaleY = diameterInKM / distance.y * api.tilesetSize.y;
        float scale = (scaleX + scaleY) / 2;

        circle.transform.localScale = new Vector3(scale, sizeY, scale);
    }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 05 Aug 2016 11:10:22 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1042#p1042</guid>
		</item>
		<item>
			<title><![CDATA[Re: How to draw a circle on the map?!]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=1040#p1040</link>
			<description><![CDATA[<p>Also, can you please tell me, how can I convert real-life radius in meters to pixels?</p>]]></description>
			<author><![CDATA[null@example.com (SweetTooth)]]></author>
			<pubDate>Fri, 05 Aug 2016 10:17:25 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=1040#p1040</guid>
		</item>
	</channel>
</rss>
