Topic: CalcAreaExample.cs

Hi,

How to refresh all drawn polygons in CalcAreaExample.cs? I have tried to removeAllItems, it worked but, I cannot draw new ones in the same session at runtime. Could you please help me?

Re: CalcAreaExample.cs

Hello.

You also need to reset the polygon field reference.

polygon = null;
Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

3 (edited by mimarilker 2019-09-18 21:38:51)

Re: CalcAreaExample.cs

Hi,

RemoveAllItems just hides the polygon, when you try to create a new polygon, the ex one starts to be visible and the new lines connect to it. I just created a numerator to see if there is a need for a time span between removing items and setting polygon null, but not worked.

  IEnumerator WaitForClear()
            {
            OnlineMapsDrawingElementManager.RemoveAllItems();
            yield return new WaitForSeconds(0.2f);
            polygon = null;
        }


        public void Clear()
        {
            StartCoroutine(WaitForClear());
           
           
        }

Re: CalcAreaExample.cs

public void Clear()
{
    if (polygon != null)
    {
        OnlineMapsDrawingElementManager.RemoveItem(polygon);
        polygon = null;
    }

    foreach (OnlineMapsMarker marker in markers) OnlineMapsMarkerManager.RemoveItem(marker);
    markers.Clear();

    markerPositions.Clear();
    changed = true;
}
Kind Regards,
Infinity Code Team.

Do not know the best way to thank the developer? Rate the asset in Asset Store!

Re: CalcAreaExample.cs

it worked, thank you!