Exemplo n.º 1
0
    private void DrawProvider(ref bool allowCreate)
    {
        EditorGUI.BeginChangeCheck();
        provider =
            (OnlineMapsProviderEnum)
            EditorGUILayout.EnumPopup(new GUIContent("Provider: ", "Provider of tiles"), provider);
        if (EditorGUI.EndChangeCheck())
        {
            mapProviderType = 0;
        }

        if (provider == OnlineMapsProviderEnum.custom)
        {
            customProviderURL = EditorGUILayout.TextField("URL: ", customProviderURL);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCustomProviderTokens = OnlineMapsEditor.Foldout(showCustomProviderTokens, "Available tokens");
            if (showCustomProviderTokens)
            {
                GUILayout.Label("{zoom}");
                GUILayout.Label("{x}");
                GUILayout.Label("{y}");
                GUILayout.Label("{quad}");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();
        }
    }
Exemplo n.º 2
0
    public OnlineMapsTile(int x, int y, int zoom, OnlineMaps api, bool isMapTile = true)
    {
        int maxX = 2 << (zoom - 1);

        if (x < 0)
        {
            x += maxX;
        }
        else if (x >= maxX)
        {
            x -= maxX;
        }

        this.x    = x;
        this.y    = y;
        this.zoom = zoom;

        OnlineMapsTile.api = api;
        this.isMapTile     = isMapTile;

        provider = api.provider;
        type     = api.type;
        labels   = api.labels;
        language = api.language;

        topLeft        = OnlineMapsUtils.TileToLatLong(x, y, zoom);
        bottomRight    = OnlineMapsUtils.TileToLatLong(x + 1, y + 1, zoom);
        globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f);

        trafficURL = String.Format("https://mts0.google.com/vt?pb=!1m4!1m3!1i{0}!2i{1}!3i{2}!2m3!1e0!2sm!3i301114286!2m6!1e2!2straffic!4m2!1soffset_polylines!2s0!5i1!2m12!1e2!2spsm!4m2!1sgid!2sl0t0vMkIqfb3hBb090479A!4m2!1ssp!2s1!5i1!8m2!13m1!14b1!3m25!2sru-RU!3sUS!5e18!12m1!1e50!12m3!1e37!2m1!1ssmartmaps!12m5!1e14!2m1!1ssolid!2m1!1soffset_polylines!12m4!1e52!2m2!1sentity_class!2s0S!12m4!1e26!2m2!1sstyles!2zcy5lOmx8cC52Om9mZixzLnQ6MXxwLnY6b2ZmLHMudDozfHAudjpvZmY!4e0", zoom, x, y);

        if (isMapTile)
        {
            tiles.Add(this);
        }
    }
    private void DrawProvider(ref bool allowCreate)
    {
        EditorGUI.BeginChangeCheck();
        provider =
            (OnlineMapsProviderEnum)
                EditorGUILayout.EnumPopup(new GUIContent("Provider: ", "Provider of tiles"), provider);
        if (EditorGUI.EndChangeCheck()) mapProviderType = 0;

        if (provider == OnlineMapsProviderEnum.custom)
        {
            customProviderURL = EditorGUILayout.TextField("URL: ", customProviderURL);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            showCustomProviderTokens = OnlineMapsEditor.Foldout(showCustomProviderTokens, "Available tokens");
            if (showCustomProviderTokens)
            {
                GUILayout.Label("{zoom}");
                GUILayout.Label("{x}");
                GUILayout.Label("{y}");
                GUILayout.Label("{quad}");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();
        }
    }
Exemplo n.º 4
0
    private void CheckBaseProps()
    {
        if (provider != _provider || type != _type || _language != language || _labels != labels)
        {
            _labels = labels;
            _language = language;
            _provider = provider;
            _type = type;

#if !UNITY_WEBGL
            int maxCount = 50;

            while (buffer.status == OnlineMapsBufferStatus.working && maxCount > 0)
            {
                Thread.Sleep(1);
                maxCount--;
            }

#if !UNITY_WEBPLAYER
            if (renderThread != null)
            {
#if UNITY_IOS
                renderThread.Interrupt();
#else
                renderThread.Abort();
#endif
            }
#endif
            renderThread = null;
#endif

            buffer.Dispose();
            buffer.status = OnlineMapsBufferStatus.wait;

            GCCollect();
            
            Redraw();
        }
        if (traffic != _traffic)
        {
            _traffic = traffic;
            OnlineMapsTile[] tiles;
            lock (OnlineMapsTile.tiles)
            {
                tiles = OnlineMapsTile.tiles.ToArray();
            }
            if (traffic)
            {
                foreach (OnlineMapsTile tile in tiles)
                {
                    if (!string.IsNullOrEmpty(tile.trafficURL))
                    {
                        tile.trafficWWW = OnlineMapsUtils.GetWWW(tile.trafficURL);
                    }
                }
            }
            else
            {
                foreach (OnlineMapsTile tile in tiles)
                {
                    tile.trafficTexture = null;
                    tile.trafficWWW = null;
                }
            }
        }
    }
Exemplo n.º 5
0
    private void OnEnable()
    {
        _instance = this;

        if (language == "") language = provider != OnlineMapsProviderEnum.nokia ? "en" : "eng";
        if (drawingElements == null) drawingElements = new List<OnlineMapsDrawingElement>();
        _provider = provider;
        _type = type;
        _language = language;

        UpdateTopLeftPosition();
        UpdateBottonRightPosition();
    }
Exemplo n.º 6
0
    public OnlineMapsTile(int x, int y, int zoom, OnlineMaps api, bool isMapTile = true)
    {
        int maxX = 2 << (zoom - 1);
        if (x < 0) x += maxX;
        else if (x >= maxX) x -= maxX;

        this.x = x;
        this.y = y;
        this.zoom = zoom;

        this.api = api;
        this.isMapTile = isMapTile;

        texture = api.defaultTileTexture;

        provider = api.provider;
        type = api.type;
        labels = api.labels;
        language = api.language;

        topLeft = OnlineMapsUtils.TileToLatLong(x, y, zoom);
        bottomRight = OnlineMapsUtils.TileToLatLong(x + 1, y + 1, zoom);
        globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f);

        if (isMapTile)
        {
            lock (tiles)
            {
                tiles.Add(this);
            }
        }
    }
Exemplo n.º 7
0
 private void CheckBaseProps()
 {
     if (provider != _provider || type != _type || _language != language)
     {
         if (renderThread != null && renderThread.IsAlive) renderThread.Abort();
         renderThread = null;
         buffer.Dispose();
         buffer.status = OnlineMapsBufferStatus.wait;
         Redraw();
         _language = language;
         _provider = provider;
         _type = type;
     }
 }
Exemplo n.º 8
0
    private void OnEnable()
    {
        _instance = this;

        if (language == "") language = provider != OnlineMapsProviderEnum.nokia ? "en" : "eng";
        if (drawingElements == null) drawingElements = new List<OnlineMapsDrawingElement>();
        _provider = provider;
        _type = type;
        _language = language;
        _position = position;
        _zoom = zoom;
    }
Exemplo n.º 9
0
    public OnlineMapsTile(int x, int y, int zoom, OnlineMaps api, bool isMapTile = true)
    {
        int maxX = 2 << (zoom - 1);
        if (x < 0) x += maxX;
        else if (x >= maxX) x -= maxX;

        this.x = x;
        this.y = y;
        this.zoom = zoom;

        OnlineMapsTile.api = api;
        this.isMapTile = isMapTile;

        provider = api.provider;
        type = api.type;
        labels = api.labels;
        language = api.language;

        topLeft = OnlineMapsUtils.TileToLatLong(x, y, zoom);
        bottomRight = OnlineMapsUtils.TileToLatLong(x + 1, y + 1, zoom);
        globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f);

        trafficURL = String.Format("https://mts0.google.com/vt?pb=!1m4!1m3!1i{0}!2i{1}!3i{2}!2m3!1e0!2sm!3i301114286!2m6!1e2!2straffic!4m2!1soffset_polylines!2s0!5i1!2m12!1e2!2spsm!4m2!1sgid!2sl0t0vMkIqfb3hBb090479A!4m2!1ssp!2s1!5i1!8m2!13m1!14b1!3m25!2sru-RU!3sUS!5e18!12m1!1e50!12m3!1e37!2m1!1ssmartmaps!12m5!1e14!2m1!1ssolid!2m1!1soffset_polylines!12m4!1e52!2m2!1sentity_class!2s0S!12m4!1e26!2m2!1sstyles!2zcy5lOmx8cC52Om9mZixzLnQ6MXxwLnY6b2ZmLHMudDozfHAudjpvZmY!4e0", zoom, x, y);

        if (isMapTile) tiles.Add(this);
    }