Topic: DrawingPoly Fill with Elevation

I've been pulled into a project so I'm not sure how much of the Online Maps code has been modified, however, in the code that I have, the draw-poly with fill has the code for the fill area commented out.

In poking around with it uncommented I noticed that the fill ignores elevation values, however the project I'm working on requires both the fill AND elevation.

How can I achieve this?

Re: DrawingPoly Fill with Elevation

Hello.

You have two ways to achieve this:
1. Available from Online Maps v2.5.5.1.
drawingElement.checkMapBoundaries = false
2. (Not recommended) Drawing as overlay.
OnlineMapsTileSetControl.drawingMode = OnlineMapsTilesetDrawingMode.overlay.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: DrawingPoly Fill with Elevation

OnlineMapsTilesetDrawingMode.overlay sorta works (I do not appear to be on 2.5.5.1, that field doesn't exist), except that when I move the marker around, the polygon that is anchored to it doesn't update when I drag the marker around, only when I zoom in and out.

This is being called from LateUpdate():

private int lastZoom = -1;
    private void UpdateRadioLocations()
    {
        float step = 360f / SEGMENTS;
        double x, y;

        Vector2 distance = OnlineMapsUtils.DistanceBetweenPoints(OnlineMaps.instance.topLeftPosition, OnlineMaps.instance.bottomRightPosition);
        float convertToKm = 1;

        float scaleX = convertToKm / distance.x * OnlineMaps.instance.tilesetSize.x;
        float scaleY = convertToKm / distance.y * OnlineMaps.instance.tilesetSize.y;
        float scale = (scaleX + scaleY) / 2;

        foreach (RadioPlacement radio in radioList)
        {
            if (radio.marker.position != radio.lastPosition || lastZoom != zoom) //this check fails on marker drag
            {
                lastZoom = zoom;
                float r = radio.radius * 2 / OnlineMapsUtils.tileSize * scale;
                radio.lastPosition = radio.marker.position;
                radio.marker.GetPosition(out x, out y);
                OnlineMapsProjection projection = OnlineMaps.instance.projection;
                projection.CoordinatesToTile(x, y, OnlineMaps.instance.zoom, out x, out y);

                for (int i = 0; i < SEGMENTS; i++)
                {
                    double px = x + Mathf.Cos(step * i * Mathf.Deg2Rad) * r;
                    double py = y + Mathf.Sin(step * i * Mathf.Deg2Rad) * r;

                    projection.TileToCoordinates(px, py, OnlineMaps.instance.zoom, out px, out py);

                    radio.points[i] = new Vector2((float)px, (float)py);
                }
                OnlineMaps.instance.Redraw();
            }
        }
    }

There's no reason changing the drawing mode should cause the marker's position to not update properly.

Re: DrawingPoly Fill with Elevation

When using drawing as overlay, after you have changed your drawing elements, you need to invoke OnlineMapsDrawingElement.MarkChanged.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: DrawingPoly Fill with Elevation

Holy cow, the performance on that is awful. Even a single 16-segment circle has noticable lag-behind time (just barely, but as this project is going to have multi-kilometer wide circles, I have the segments variable set up at 64 and the script execution time on that is 200ms!)

Re: DrawingPoly Fill with Elevation

As I wrote earlier this way is not recommended for use.
Currently, the best way is drawElement.checkMapBoundaries = false.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: DrawingPoly Fill with Elevation

Right, but the version of Online Maps I have does not seem to have it.
Thanks though.

Re: DrawingPoly Fill with Elevation

Just update Online Maps using Unity Asset Store or the built-in update system.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: DrawingPoly Fill with Elevation

I will see about doing that. I will need to talk with my team and insure that the update doesn't cause issues somewhere else.

10 (edited by Draco18s 2017-04-18 14:57:47)

Re: DrawingPoly Fill with Elevation

Got the updated package from my counterpart, version 2.5.7.1 with the checkMapBoundaries variable.
Setting it to false throws a runtime error:

IndexOutOfRangeException: Array index is out of range.
OnlineMapsDrawingPoly.DrawOnTileset (.OnlineMapsTileSetControl control, Int32 index) (at Assets/Infinity Code/Online maps/Scripts/Drawing/OnlineMapsDrawingPoly.cs:275)
OnlineMapsTileSetControl.UpdateControl () (at Assets/Infinity Code/Online maps/Scripts/Controls/OnlineMapsTileSetControl.cs:1250)
OnlineMaps.CheckBufferComplete () (at Assets/Infinity Code/Online maps/Scripts/OnlineMaps.cs:876)
OnlineMaps.LateUpdate () (at Assets/Infinity Code/Online maps/Scripts/OnlineMaps.cs:1137)

Appears that...
internalPoints is a size-one array and is having its only point removed.

I do initially set the polygon's points as an array of Vector2.zero, but they do get modified later.
Adding if (fillTriangles.Length == 0) return; fixes things.

Re: DrawingPoly Fill with Elevation

Thank you. We added additional checks for the arrays.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.