using System; using System.Collections.Generic; using System.Linq; using UnityEngine; public class TestDrawingAPIWithElevation:MonoBehaviour { private List polyPoints; private void OnGUI() { if (GUI.Button(new Rect(5, 5, 100, 30), "Redraw")) { // Marks that need to redraw the drawing elements. // It need to use only if something has changed. OnlineMapsDrawingElement.MarkChanged(); // Redraw map. OnlineMaps.instance.Redraw(); } } private void Start() { OnlineMaps api = OnlineMaps.instance; double[,] coords = { { 25.703806054376393, 44.53245327694106 }, { 25.703804693034506, 44.53244372481203 }, { 25.703737365876005, 44.532447852385324 }, { 25.70369245260592, 44.53241869185757 }, { 25.703668498482624, 44.532403139310425 }, { 25.7036291699531, 44.53240669801435 }, { 25.703625073949034, 44.53237745085631 }, { 25.70361775362749, 44.532325180666255 }, { 25.703689573505923, 44.53232033204781 }, { 25.70374618547291, 44.53231651009466 }, { 25.703806333133866, 44.53235837846979 }, { 25.70393934106813, 44.532345123402045 }, { 25.704015680368517, 44.532195550804424 }, { 25.704125823257158, 44.53211161773481 }, { 25.703988520644465, 44.532105020385906 }, { 25.703939276573184, 44.53215005664679 }, { 25.703796773422933, 44.53214431984583 }, { 25.703802498089637, 44.53204405852175 }, { 25.703894027998327, 44.53204804279978 }, { 25.70389505134437, 44.53204138052475 }, { 25.70416622616025, 44.53205379779829 }, { 25.704166270281014, 44.53204819735022 }, { 25.70419279220568, 44.53204824784729 }, { 25.704210766731286, 44.53206151765937 }, { 25.704238359939996, 44.53208150979637 }, { 25.70424146909448, 44.5322050647938 }, { 25.704256858466724, 44.53222137874446 }, { 25.704209548539055, 44.53228255509981 }, { 25.704185270298844, 44.53233323369645 }, { 25.704174669546884, 44.53236601818057 }, { 25.70417045245381, 44.53240000525724 }, { 25.70417427800096, 44.53242071012687 }, { 25.704176032096093, 44.532430203747076 }, { 25.703971183012882, 44.532439766150276 }, { 25.703970304069355, 44.5324285067816 }, { 25.70390046960213, 44.53243358118934 }, { 25.703901779117437, 44.53244599767316 }, { 25.703806054376393, 44.53245327694106 } }; polyPoints = new List(); for (int i = 0; i < coords.GetLength(0); i++) { Vector2 c = new Vector2((float)coords[i, 1], (float)coords[i, 0]); polyPoints.Add(c); OnlineMapsMarker marker = api.AddMarker(c, i.ToString()); marker.customData = i; marker.OnDrag += OnMarkerDrag; } OnlineMapsDrawingPoly poly = new OnlineMapsDrawingPoly(polyPoints, Color.green, 3, new Color(0, 0, 1, 0.5f)); api.AddDrawingElement(poly); float x = polyPoints.Average(p => p.x); float y = polyPoints.Average(p => p.y); // Specifies that need to draw in front overlay. OnlineMapsTileSetControl.instance.drawingMode = OnlineMapsTilesetDrawingMode.overlay; api.position = new Vector2(x, y); api.zoom = 19; } private void OnMarkerDrag(OnlineMapsMarkerBase marker) { polyPoints[(int) marker.customData] = marker.position; OnlineMapsDrawingElement.MarkChanged(); OnlineMaps.instance.Redraw(); } }