Example #1
0
    private static void LoadSettings(OnlineMapsXML el, OnlineMaps api)
    {
        api.position = el.Get <Vector2>("Position");
        api.zoom     = el.Get <int>("Zoom");

        if (api.target == OnlineMapsTarget.texture)
        {
            api.texture = GetObject(el.Get <int>("Texture")) as Texture2D;
        }
        else
        {
            api.tilesetWidth  = el.Get <int>("TilesetWidth");
            api.tilesetHeight = el.Get <int>("TilesetHeight");
            api.tilesetSize   = el.Get <Vector2>("TilesetSize");
        }

        api.source  = (OnlineMapsSource)el.Get <int>("Source");
        api.mapType = el.Get("MapType");
        OnlineMapsProvider.MapType activeType = OnlineMapsProvider.FindMapType(api.mapType);
        if (activeType.isCustom)
        {
            api.customProviderURL = el.Get <string>("CustomProviderURL");
        }
        api.labels                   = el.Get <bool>("Labels");
        api.traffic                  = el.Get <bool>("Traffic");
        api.redrawOnPlay             = el.Get <bool>("RedrawOnPlay");
        api.useSmartTexture          = el.Get <bool>("UseSmartTexture");
        api.emptyColor               = el.Get <Color>("EmptyColor");
        api.defaultTileTexture       = GetObject(el.Get <int>("DefaultTileTexture")) as Texture2D;
        api.tooltipBackgroundTexture = GetObject(el.Get <int>("TooltipTexture")) as Texture2D;
        api.defaultMarkerTexture     = GetObject(el.Get <int>("DefaultMarkerTexture")) as Texture2D;
        api.defaultMarkerAlign       = (OnlineMapsAlign)el.Get <int>("DefaultMarkerAlign");
        api.showMarkerTooltip        = (OnlineMapsShowMarkerTooltip)el.Get <int>("ShowMarkerTooltip");
        api.useSoftwareJPEGDecoder   = el.Get <bool>("UseSoftwareJPEGDecoder");
    }
        /// <summary>
        /// Draws UI elements using IMGUI
        /// </summary>
        private void OnGUI()
        {
            if (GUILayout.Button("Set DigitalGlobe"))
            {
                // Switch to DigitalGlobe / Satellite
                string mapTypeID = "digitalglobe.satellite";

                OnlineMaps.instance.mapType = mapTypeID;

                // Get map type
                OnlineMapsProvider.MapType mapType = OnlineMapsProvider.FindMapType(mapTypeID);

                // Try get access token field from map type
                OnlineMapsProvider.ExtraField field = GetExtraField(mapType.extraFields, "accesstoken");

                // If the field is not in the map type, try to get it from the provider
                if (field == null)
                {
                    field = GetExtraField(mapType.provider.extraFields, "accesstoken");
                }

                // If the field is present, set value
                if (field != null)
                {
                    field.value = "My DigitalGlobe Token";
                }
            }
        }
Example #3
0
    private void OnEnable()
    {
#if UNITY_EDITOR
        EditorApplication.update += CheckScriptCompiling;
#endif

        _instance = this;

        tooltipDrawer = new OnlineMapsGUITooltipDrawer(this);

        activeType = OnlineMapsProvider.FindMapType(mapType);
        _mapType   = mapType = activeType.fullID;

        trafficProvider = OnlineMapsTrafficProvider.GetByID(trafficProviderID);

        if (language == "")
        {
            language = activeType.provider.twoLetterLanguage ? "en" : "eng";
        }

        _language          = language;
        _labels            = labels;
        _traffic           = traffic;
        _trafficProviderID = trafficProviderID;
        izoom = (int)_zoom;

        UpdateCorners();
    }
    private void Start()
    {
        // style1 = @"http://127.0.0.1:8000/roadmap?{zoom}{x}{y}";

        //ConfigFile cf = jsonConf.configFile;
        //if (cf != null)
        //{
        //    style1 = cf.MapHttpServer;
        //}
        Debug.Log(style1);
        OnlineMapsProvider.MapType mType = new OnlineMapsProvider.MapType("style1");
        mType.urlWithLabels = style1;
        // Create a new provider
        var provider = OnlineMapsProvider.Create("myprovider");

        provider.AppendTypes(mType);
        //provider .AppendTypes(
        //    // Create a new map types
        //    new OnlineMapsProvider.MapType("style1") { urlWithLabels = style1 + mapboxAccessToken, }
        //   // new OnlineMapsProvider.MapType("style2") { urlWithLabels = style2 + mapboxAccessToken, }
        //);

        // Select map type
        OnlineMaps.instance.mapType = "myprovider.style1";
    }
Example #5
0
 public static void OpenWindow()
 {
     GetWindow <OnlineMapsWizard>(true, "Create Map", true);
     activeMapType  = OnlineMapsProvider.FindMapType("arcgis");
     providers      = OnlineMapsProvider.GetProviders();
     providersTitle = OnlineMapsProvider.GetProvidersTitle();
     providerIndex  = activeMapType.provider.index;
 }
Example #6
0
 /// <summary>
 /// Logs providers id and map types
 /// </summary>
 private void LogTypeList()
 {
     // Gets all providers
     OnlineMapsProvider[] providers = OnlineMapsProvider.GetProviders();
     foreach (OnlineMapsProvider provider in providers)
     {
         Debug.Log(provider.id);
         foreach (OnlineMapsProvider.MapType type in provider.types)
         {
             Debug.Log(type);
         }
     }
 }
    /// <summary>
    /// Creates a new provider, with the specified title.
    /// </summary>
    /// <param name="title">Provider title. Provider id = title.ToLower().</param>
    /// <returns>Instance of provider</returns>
    public static OnlineMapsProvider Create(string title)
    {
        OnlineMapsProvider provider = new OnlineMapsProvider(title);

        provider._types = new MapType[0];
        if (providers == null)
        {
            InitProviders();
        }
        Array.Resize(ref providers, providers.Length + 1);
        providers[providers.Length - 1] = provider;
        return(provider);
    }
    private void OnEnable()
    {
        activeMapType  = OnlineMapsProvider.FindMapType("arcgis");
        providers      = OnlineMapsProvider.GetProviders();
        providersTitle = OnlineMapsProvider.GetProvidersTitle();
        providerIndex  = activeMapType.provider.index;

        InitSteps();
        defaultTilesetShader = Shader.Find("Infinity Code/Online Maps/Tileset");
        tilesetShader        = defaultTilesetShader;
        markerShader         = Shader.Find("Transparent/Diffuse");
        drawingShader        = Shader.Find("Infinity Code/Online Maps/Tileset DrawingElement");
        activeCamera         = Camera.main;
    }
Example #9
0
    private void OnEnable()
    {
        try
        {
            CacheSerializedProperties();
            map     = (OnlineMaps)target;
            control = map.GetComponent <OnlineMapsControlBase>();

            savableItems = map.GetComponents <IOnlineMapsSavableComponent>().SelectMany(c => c.GetSavableItems()).OrderByDescending(s => s.priority).ThenBy(s => s.label).ToList();

            providers      = OnlineMapsProvider.GetProviders();
            providersTitle = providers.Select(p => p.title).ToArray();

            trafficProviders     = OnlineMapsTrafficProvider.GetProviders();
            cTrafficProviders    = trafficProviders.Select(p => new GUIContent(p.title)).ToArray();
            trafficProviderIndex = 0;
            for (int i = 0; i < trafficProviders.Length; i++)
            {
                if (trafficProviders[i].id == pTrafficProviderID.stringValue)
                {
                    trafficProviderIndex = i;
                    break;
                }
            }

            if (pTooltipTexture.objectReferenceValue == null)
            {
                pTooltipTexture.objectReferenceValue = OnlineMapsEditorUtils.LoadAsset <Texture2D>("Textures\\Tooltip.psd");
            }

            updateAvailableContent = new GUIContent("Update Available", OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\update_available.png"), "Update Available");
            wizardIconContent      = new GUIContent(OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\WizardIcon.png"), "Wizard");

            OnlineMapsUpdater.CheckNewVersionAvailable();

            mapType       = OnlineMapsProvider.FindMapType(pMapType.stringValue);
            providerIndex = mapType.provider.index;

            serializedObject.ApplyModifiedProperties();

            map.floatZoom = map.CheckMapSize(map.floatZoom);
        }
        catch (Exception e)
        {
            Debug.Log(e.Message + "\n" + e.StackTrace);
            //throw;
        }
    }
Example #10
0
        private void Start()
        {
            // Create a new provider
            OnlineMapsProvider.Create("myprovider").AppendTypes(
                // Create a new map types
                new OnlineMapsProvider.MapType("style1")
            {
                urlWithLabels = style1 + mapboxAccessToken,
            },
                new OnlineMapsProvider.MapType("style2")
            {
                urlWithLabels = style2 + mapboxAccessToken,
            }
                );

            // Select map type
            OnlineMaps.instance.mapType = "myprovider.style1";
        }
Example #11
0
        /// <summary>
        /// This method is called when the script starts
        /// </summary>
        private void Start()
        {
            // Register a new provider and map type
            OnlineMapsProvider.Create("mywms").AppendTypes(
                new OnlineMapsProvider.MapType("style1")
            {
                urlWithLabels = url
            }
                );

            // Select a new map type
            OnlineMaps.instance.mapType = "mywms.style1";

            // Subscribe to replace token event
            OnlineMapsTile.OnReplaceURLToken += OnReplaceUrlToken;

            OnlineMaps.instance.SetPositionAndZoom(29.254738, 40.8027188, 14);
        }
Example #12
0
    private void OnEnable()
    {
        CacheSerializedProperties();
        api = (OnlineMaps)target;

        providers      = OnlineMapsProvider.GetProviders();
        providersTitle = providers.Select(p => p.title).ToArray();

        if (string.IsNullOrEmpty(pMapType.stringValue))
        {
            pMapType.stringValue = OnlineMapsProvider.Upgrade(pProvider.enumValueIndex, pType.intValue);
        }

        trafficProviders     = OnlineMapsTrafficProvider.GetProviders();
        cTrafficProviders    = trafficProviders.Select(p => new GUIContent(p.title)).ToArray();
        trafficProviderIndex = 0;
        for (int i = 0; i < trafficProviders.Length; i++)
        {
            if (trafficProviders[i].id == pTrafficProviderID.stringValue)
            {
                trafficProviderIndex = i;
                break;
            }
        }

        if (pDefaultMarkerTexture.objectReferenceValue == null)
        {
            pDefaultMarkerTexture.objectReferenceValue = OnlineMapsEditorUtils.LoadAsset <Texture2D>("Textures\\Markers\\DefaultMarker.png");
        }
        if (pTooltipTexture.objectReferenceValue == null)
        {
            pTooltipTexture.objectReferenceValue = OnlineMapsEditorUtils.LoadAsset <Texture2D>("Textures\\Tooltip.psd");
        }

        updateAvailableContent = new GUIContent("Update Available", OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\update_available.png"), "Update Available");
        wizardIconContent      = new GUIContent(OnlineMapsEditorUtils.LoadAsset <Texture2D>("Icons\\WizardIcon.png"), "Wizard");

        OnlineMapsUpdater.CheckNewVersionAvailable();

        mapType       = OnlineMapsProvider.FindMapType(pMapType.stringValue);
        providerIndex = mapType.provider.index;

        serializedObject.ApplyModifiedProperties();
    }
Example #13
0
    private void OnEnable()
    {
        CacheSerializedProperties();
        api = (OnlineMaps)target;

        providers      = OnlineMapsProvider.GetProviders();
        providersTitle = providers.Select(p => p.title).ToArray();

        if (string.IsNullOrEmpty(pMapType.stringValue))
        {
            pMapType.stringValue = OnlineMapsProvider.Upgrade(pProvider.enumValueIndex, pType.intValue);
        }

        if (pDefaultMarkerTexture.objectReferenceValue == null)
        {
            pDefaultMarkerTexture.objectReferenceValue = GetIcon("DefaultMarker.png");
        }
        if (pTooltipTexture.objectReferenceValue == null)
        {
            pTooltipTexture.objectReferenceValue = GetIcon("Tooltip.psd");
        }

        string[] files = Directory.GetFiles("Assets", "update_available.png", SearchOption.AllDirectories);
        if (files.Length > 0)
        {
            Texture updateAvailableIcon = AssetDatabase.LoadAssetAtPath(files[0], typeof(Texture)) as Texture;
            updateAvailableContent = new GUIContent("Update Available", updateAvailableIcon, "Update Available");
        }

        OnlineMapsUpdater.CheckNewVersionAvailable();

        mapType       = OnlineMapsProvider.FindMapType(pMapType.stringValue);
        providerIndex = mapType.provider.index;

        serializedObject.ApplyModifiedProperties();
    }
Example #14
0
    private static void InitProviders()
    {
        providers = new []
        {
            new OnlineMapsProvider("arcgis", "ArcGIS (Esri)")
            {
                url    = "https://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{zoom}/{y}/{x}",
                _types = new []
                {
                    new MapType("WorldImagery")
                    {
                        variantWithoutLabels = "World_Imagery"
                    },
                    new MapType("WorldTopoMap")
                    {
                        variantWithLabels = "World_Topo_Map"
                    },
                    new MapType("WorldStreetMap")
                    {
                        variantWithLabels = "World_Street_Map"
                    },
                    new MapType("DeLorme")
                    {
                        variantWithLabels = "Specialty/DeLorme_World_Base_Map"
                    },
                    new MapType("WorldTerrain")
                    {
                        variantWithoutLabels = "World_Terrain_Base"
                    },
                    new MapType("WorldShadedRelief")
                    {
                        variantWithoutLabels = "World_Shaded_Relief"
                    },
                    new MapType("WorldPhysical")
                    {
                        variantWithoutLabels = "World_Physical_Map"
                    },
                    new MapType("OceanBasemap")
                    {
                        variantWithLabels = "Ocean_Basemap"
                    },
                    new MapType("NatGeoWorldMap")
                    {
                        variantWithLabels = "NatGeo_World_Map"
                    },
                    new MapType("WorldGrayCanvas")
                    {
                        variantWithLabels = "Canvas/World_Light_Gray_Base"
                    },
                }
            },
            new OnlineMapsProvider("CartoDB")
            {
                url    = "https://cartodb-basemaps-d.global.ssl.fastly.net/{variant}/{z}/{x}/{y}.png",
                _types = new []
                {
                    new MapType("Positron")
                    {
                        variantWithLabels    = "light_all",
                        variantWithoutLabels = "light_nolabels"
                    },
                    new MapType("DarkMatter")
                    {
                        variantWithLabels    = "dark_all",
                        variantWithoutLabels = "dark_nolabels"
                    },
                }
            },
            new OnlineMapsProvider("DigitalGlobe")
            {
                url    = "https://a.tiles.mapbox.com/v4/digitalglobe.{variant}/{zoom}/{x}/{y}.jpg?access_token={accesstoken}",
                _types = new []
                {
                    new MapType("Satellite")
                    {
                        variantWithoutLabels = "nal0g75k"
                    },
                    new MapType("Street")
                    {
                        variantWithLabels = "nako6329",
                    },
                    new MapType("Terrain")
                    {
                        variantWithLabels = "nako1fhg",
                    },
                },
                extraFields = new []
                {
                    new ExtraField("Access Token", "accesstoken"),
                }
            },
            new OnlineMapsProvider("google", "Google Maps")
            {
                hasLanguage = true,
                _types      = new[]
                {
                    new MapType(SATELLITE)
                    {
                        urlWithLabels    = "https://mt{rnd0-3}.googleapis.com/vt/lyrs=y&hl={lng}&x={x}&y={y}&z={zoom}",
                        urlWithoutLabels = "https://khm{rnd0-3}.googleapis.com/kh?v=726&hl={lng}&x={x}&y={y}&z={zoom}",
                    },
                    new MapType(RELIEF)
                    {
                        urlWithLabels = "https://mts{rnd0-3}.google.com/vt/lyrs=t@131,r@216000000&src=app&hl={lng}&x={x}&y={y}&z={zoom}&s="
                    },
                    new MapType(TERRAIN)
                    {
                        urlWithLabels = "https://mt{rnd0-3}.googleapis.com/vt?pb=!1m4!1m3!1i{zoom}!2i{x}!3i{y}!2m3!1e0!2sm!3i295124088!3m9!2s{lng}!3sUS!5e18!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!4e0"
                    }
                }
            },
            new OnlineMapsProvider("Hydda")
            {
                url    = "https://{s}.tile.openstreetmap.se/hydda/{variant}/{z}/{x}/{y}.png",
                _types = new []
                {
                    new MapType("Full")
                    {
                        variantWithLabels = "full"
                    },
                    new MapType("Base")
                    {
                        variantWithLabels = "base"
                    },
                    new MapType("RoadsAndLabels")
                    {
                        variantWithLabels = "roads_and_labels"
                    },
                }
            },
            new OnlineMapsProvider("Mapbox classic")
            {
                url           = "https://b.tiles.mapbox.com/v4/{mapid}/{zoom}/{x}/{y}.png?access_token={accesstoken}",
                labelsEnabled = true,

                _types = new []
                {
                    new MapType("Map"),
                },

                extraFields = new []
                {
                    new ExtraField("Map ID", "mapid"),
                    new ExtraField("Access Token", "accesstoken"),
                }
            },
            new OnlineMapsProvider("MapQuest")
            {
                url    = "https://a.tiles.mapbox.com/v4/{variant}/{zoom}/{x}/{y}.png?access_token={accesstoken}",
                _types = new []
                {
                    new MapType(SATELLITE)
                    {
                        variantWithoutLabels = "mapquest.satellite"
                    },
                    new MapType("Streets")
                    {
                        variantWithLabels = "mapquest.streets"
                    },
                },
                extraFields = new []
                {
                    new ToggleExtraGroup("Anonymous", true, new []
                    {
                        new ExtraField("Access Token", "accesstoken", "pk.eyJ1IjoibWFwcXVlc3QiLCJhIjoiY2Q2N2RlMmNhY2NiZTRkMzlmZjJmZDk0NWU0ZGJlNTMifQ.mPRiEubbajc6a5y9ISgydg")
                    })
                },
            },
            new OnlineMapsProvider("mapy", "Mapy.CZ")
            {
                url    = "https://m{rnd0-4}.mapserver.mapy.cz/{variant}/{zoom}-{x}-{y}",
                _types = new []
                {
                    new MapType(SATELLITE)
                    {
                        variantWithoutLabels = "ophoto-m"
                    },
                    new MapType("Travel")
                    {
                        variantWithLabels = "wturist-m"
                    },
                    new MapType("Winter")
                    {
                        variantWithLabels = "wturist_winter-m"
                    },
                    new MapType("Geographic")
                    {
                        variantWithLabels = "zemepis-m"
                    },
                    new MapType("Summer")
                    {
                        variantWithLabels = "turist_aquatic-m"
                    },
                    new MapType("19century", "19th century")
                    {
                        variantWithLabels = "army2-m"
                    },
                }
            },
            new OnlineMapsProvider("nokia", "Nokia Maps (here.com)")
            {
                url = "https://{rnd1-4}.maps.nlp.nokia.com/maptile/2.1/{prop}/newest/{variant}/{zoom}/{x}/{y}/256/png8?lg={lng}&app_id={appid}&app_code={appcode}",
                twoLetterLanguage = false,
                hasLanguage       = true,
                labelsEnabled     = true,
                prop = "maptile",

                _types = new []
                {
                    new MapType(SATELLITE)
                    {
                        variantWithLabels    = "hybrid.day",
                        variantWithoutLabels = "satellite.day",
                    },
                    new MapType(TERRAIN)
                    {
                        variant           = "terrain.day",
                        propWithoutLabels = "basetile",
                    },
                    new MapType(MAP)
                    {
                        variant           = "normal.day",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalDayCustom")
                    {
                        variant           = "normal.day.custom",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalDayGrey")
                    {
                        variant           = "normal.day.grey",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalDayMobile")
                    {
                        variant           = "normal.day.mobile",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalDayGreyMobile")
                    {
                        variant           = "normal.day.grey.mobile",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalDayTransit")
                    {
                        variant           = "normal.day.transit",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalDayTransitMobile")
                    {
                        variant           = "normal.day.transit.mobile",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalNight")
                    {
                        variant           = "normal.night",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalNightMobile")
                    {
                        variant           = "normal.night.mobile",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalNightGrey")
                    {
                        variant           = "normal.night.grey",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("normalNightGreyMobile")
                    {
                        variant           = "normal.night.grey.mobile",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("carnavDayGrey")
                    {
                        variantWithLabels = "carnav.day.grey",
                        propWithoutLabels = "basetile",
                    },
                    new MapType("pedestrianDay")
                    {
                        variantWithLabels = "pedestrian.day"
                    },
                    new MapType("pedestrianNight")
                    {
                        variantWithLabels = "pedestrian.night"
                    },
                },

                extraFields = new []
                {
                    new ToggleExtraGroup("Anonymous", true, new []
                    {
                        new ExtraField("App ID", "appid", "xWVIueSv6JL0aJ5xqTxb"),
                        new ExtraField("App Code", "appcode", "djPZyynKsbTjIUDOBcHZ2g"),
                    })
                }
            },
            new OnlineMapsProvider("OpenMapSurfer")
            {
                url    = "http://korona.geog.uni-heidelberg.de/tiles/{variant}/x={x}&y={y}&z={z}",
                _types = new []
                {
                    new MapType("Roads")
                    {
                        variantWithLabels = "roads"
                    },
                    new MapType("AdminBounds")
                    {
                        variantWithLabels = "adminb"
                    },
                    new MapType("Grayscale")
                    {
                        variantWithLabels = "roadsg"
                    },
                }
            },
            new OnlineMapsProvider("osm", "OpenStreetMap")
            {
                _types = new []
                {
                    new MapType("Mapnik")
                    {
                        urlWithLabels = "https://a.tile.openstreetmap.org/{zoom}/{x}/{y}.png"
                    },
                    new MapType("BlackAndWhite")
                    {
                        urlWithLabels = "http://a.tiles.wmflabs.org/bw-mapnik/{zoom}/{x}/{y}.png"
                    },
                    new MapType("DE")
                    {
                        urlWithLabels = "http://a.tile.openstreetmap.de/tiles/osmde/{zoom}/{x}/{y}.png"
                    },
                    new MapType("France")
                    {
                        urlWithLabels = "https://a.tile.openstreetmap.fr/osmfr/{zoom}/{x}/{y}.png"
                    },
                    new MapType("HOT")
                    {
                        urlWithLabels = "https://a.tile.openstreetmap.fr/hot/{zoom}/{x}/{y}.png"
                    },
                }
            },
            new OnlineMapsProvider("OpenTopoMap")
            {
                _types = new []
                {
                    new MapType("OpenTopoMap")
                    {
                        urlWithLabels = "https://a.tile.opentopomap.org/{z}/{x}/{y}.png"
                    },
                }
            },
            new OnlineMapsProvider("OpenWeatherMap")
            {
                url    = "http://a.tile.openweathermap.org/map/{variant}/{z}/{x}/{y}.png",
                _types = new []
                {
                    new MapType("Clouds")
                    {
                        variantWithoutLabels = "clouds"
                    },
                    new MapType("CloudsClassic")
                    {
                        variantWithoutLabels = "clouds_cls"
                    },
                    new MapType("Precipitation")
                    {
                        variantWithoutLabels = "precipitation"
                    },
                    new MapType("PrecipitationClassic")
                    {
                        variantWithoutLabels = "precipitation_cls"
                    },
                    new MapType("Rain")
                    {
                        variantWithoutLabels = "rain"
                    },
                    new MapType("RainClassic")
                    {
                        variantWithoutLabels = "rain_cls"
                    },
                    new MapType("Pressure")
                    {
                        variantWithoutLabels = "pressure"
                    },
                    new MapType("PressureContour")
                    {
                        variantWithoutLabels = "pressure_cntr"
                    },
                    new MapType("Wind")
                    {
                        variantWithoutLabels = "wind"
                    },
                    new MapType("Temperature")
                    {
                        variantWithoutLabels = "temp"
                    },
                    new MapType("Snow")
                    {
                        variantWithoutLabels = "snow"
                    },
                }
            },
            new OnlineMapsProvider("Stamen")
            {
                url    = "https://stamen-tiles-a.a.ssl.fastly.net/{variant}/{z}/{x}/{y}.png",
                _types = new []
                {
                    new MapType("Toner")
                    {
                        variantWithLabels = "toner"
                    },
                    new MapType("TonerBackground")
                    {
                        variantWithoutLabels = "toner-background"
                    },
                    new MapType("TonerHybrid")
                    {
                        variantWithLabels = "toner-hybrid"
                    },
                    new MapType("TonerLines")
                    {
                        variantWithLabels = "toner-lines"
                    },
                    new MapType("TonerLabels")
                    {
                        variantWithLabels = "toner-labels"
                    },
                    new MapType("TonerLite")
                    {
                        variantWithLabels = "toner-lite"
                    },
                    new MapType("Watercolor")
                    {
                        variantWithoutLabels = "watercolor"
                    },
                }
            },
            new OnlineMapsProvider("Thunderforest")
            {
                url    = "https://a.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png",
                _types = new []
                {
                    new MapType("OpenCycleMap")
                    {
                        variantWithLabels = "cycle"
                    },
                    new MapType("Transport")
                    {
                        variantWithLabels = "transport"
                    },
                    new MapType("TransportDark")
                    {
                        variantWithLabels = "transport-dark"
                    },
                    new MapType("SpinalMap")
                    {
                        variantWithLabels = "spinal-map"
                    },
                    new MapType("Landscape")
                    {
                        variantWithLabels = "landscape"
                    },
                    new MapType("Outdoors")
                    {
                        variantWithLabels = "outdoors"
                    },
                    new MapType("Pioneer")
                    {
                        variantWithLabels = "pioneer"
                    },
                }
            },
            new OnlineMapsProvider("TianDiTu")
            {
                _types = new []
                {
                    new MapType("Normal")
                    {
                        urlWithoutLabels = "http://t{rnd0-7}.tianditu.cn/DataServer?T=vec_w&X={x}&Y={y}&L={z}"
                    },
                    new MapType(SATELLITE)
                    {
                        urlWithoutLabels = "http://t{rnd0-7}.tianditu.cn/DataServer?T=img_w&X={x}&Y={y}&L={z}"
                    },
                    new MapType(TERRAIN)
                    {
                        urlWithoutLabels = "http://t{rnd0-7}.tianditu.cn/DataServer?T=ter_w&X={x}&Y={y}&L={z}"
                    },
                }
            },
            new OnlineMapsProvider("virtualearth", "Virtual Earth (Bing Maps)")
            {
                hasLanguage = true,
                _types      = new []
                {
                    new MapType("Aerial")
                    {
                        urlWithoutLabels = "https://t{rnd0-4}.ssl.ak.tiles.virtualearth.net/tiles/a{quad}.jpeg?mkt={lng}&g=1457&n=z",
                        urlWithLabels    = "https://t{rnd0-4}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{quad}?mkt={lng}&it=A,G,L,LA&og=30&n=z"
                    },
                    new MapType("Road")
                    {
                        urlWithLabels = "https://t{rnd0-4}.ssl.ak.dynamic.tiles.virtualearth.net/comp/ch/{quad}?mkt={lng}&it=G,VE,BX,L,LA&og=30&n=z"
                    }
                }
            },
            new OnlineMapsProvider("yandex", "Yandex Maps")
            {
                projection = new OnlineMapsProjectionWGS84(),
                _types     = new []
                {
                    new MapType(MAP)
                    {
                        hasLanguage   = true,
                        urlWithLabels = "https://vec0{rnd1-4}.maps.yandex.net/tiles?l=map&v=4.65.1&x={x}&y={y}&z={zoom}&scale=1&lang={lng}"
                    },
                    new MapType(SATELLITE)
                    {
                        urlWithoutLabels = "https://sat0{rnd1-4}.maps.yandex.net/tiles?l=sat&v=3.261.0&x={x}&y={y}&z={zoom}"
                    },
                }
            },
            new OnlineMapsProvider("Other")
            {
                _types = new []
                {
                    new MapType("AMap Satellite")
                    {
                        urlWithoutLabels = "https://webst02.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={zoom}"
                    },
                    new MapType("AMap Terrain")
                    {
                        urlWithLabels = "https://webrd03.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={zoom}"
                    },
                    new MapType("MtbMap")
                    {
                        urlWithLabels = "http://tile.mtbmap.cz/mtbmap_tiles/{z}/{x}/{y}.png"
                    },
                    new MapType("HikeBike")
                    {
                        urlWithLabels = "https://a.tiles.wmflabs.org/hikebike/{z}/{x}/{y}.png"
                    },
                }
            },
            new OnlineMapsProvider("Custom")
            {
                _types = new []
                {
                    new MapType("Custom")
                    {
                        isCustom = true
                    }
                }
            }
        };

        for (int i = 0; i < providers.Length; i++)
        {
            OnlineMapsProvider provider = providers[i];
            provider.index = i;
            for (int j = 0; j < provider._types.Length; j++)
            {
                MapType type = provider._types[j];
                type.provider = provider;
                type.fullID   = provider.id + "." + type.id;
                type.index    = j;
            }
        }
    }
Example #15
0
    private void CheckBaseProps()
    {
        if (mapType != _mapType)
        {
            activeType = OnlineMapsProvider.FindMapType(mapType);
            _mapType   = mapType = activeType.fullID;
            if (_buffer != null)
            {
                _buffer.UnloadOldTypes();
            }
            Redraw();
        }

        if (_language != language || _labels != labels)
        {
            _labels   = labels;
            _language = language;

            if (_buffer != null)
            {
                _buffer.Dispose();
                _buffer = null;
#if NETFX_CORE
                if (renderThread != null)
                {
                    renderThread.Dispose();
                }
#endif
#if !UNITY_WEBGL
                renderThread = null;
#endif
            }

            Redraw();
        }
        if (traffic != _traffic || trafficProviderID != _trafficProviderID)
        {
            _traffic = traffic;

            _trafficProviderID = trafficProviderID;
            trafficProvider    = OnlineMapsTrafficProvider.GetByID(trafficProviderID);

            OnlineMapsTile[] tiles;
            lock (OnlineMapsTile.lockTiles)
            {
                tiles = OnlineMapsTile.tiles.ToArray();
            }
            if (traffic)
            {
                foreach (OnlineMapsTile tile in tiles)
                {
                    OnlineMapsRasterTile rTile = tile as OnlineMapsRasterTile;
                    rTile.trafficProvider        = trafficProvider;
                    rTile.trafficWWW             = new OnlineMapsWWW(rTile.trafficURL);
                    rTile.trafficWWW["tile"]     = tile;
                    rTile.trafficWWW.OnComplete += OnlineMapsTileManager.OnTrafficWWWComplete;
                    if (rTile.trafficTexture != null)
                    {
                        OnlineMapsUtils.Destroy(rTile.trafficTexture);
                        rTile.trafficTexture = null;
                    }
                }
            }
            else
            {
                foreach (OnlineMapsTile tile in tiles)
                {
                    OnlineMapsRasterTile rTile = tile as OnlineMapsRasterTile;
                    if (rTile.trafficTexture != null)
                    {
                        OnlineMapsUtils.Destroy(rTile.trafficTexture);
                        rTile.trafficTexture = null;
                    }
                    rTile.trafficWWW = null;
                }
            }
            Redraw();
        }
    }
Example #16
0
    private void OnEnable()
    {
        activeMapType  = OnlineMapsProvider.FindMapType("arcgis");
        providers      = OnlineMapsProvider.GetProviders();
        providersTitle = OnlineMapsProvider.GetProvidersTitle();
        providerIndex  = activeMapType.provider.index;

#if UNITY_2019_1_OR_NEWER
        bool useSRP = UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset != null;
#else
        bool useSRP = false;
#endif

        if (useSRP)
        {
            string[] assets = AssetDatabase.FindAssets("TilesetPBRShader");
            if (assets.Length > 0)
            {
                defaultTilesetShader = AssetDatabase.LoadAssetAtPath <Shader>(AssetDatabase.GUIDToAssetPath(assets[0]));
            }
            else
            {
                defaultTilesetShader = Shader.Find("Infinity Code/Online Maps/Tileset Cutout");
            }
            tilesetShader = defaultTilesetShader;

            assets = AssetDatabase.FindAssets("TilesetPBRMarkerShader");
            if (assets.Length > 0)
            {
                markerShader = AssetDatabase.LoadAssetAtPath <Shader>(AssetDatabase.GUIDToAssetPath(assets[0]));
            }
            else
            {
                markerShader = Shader.Find("Transparent/Diffuse");
            }

            assets = AssetDatabase.FindAssets("TilesetPBRDrawingElement");
            if (assets.Length > 0)
            {
                drawingShader = AssetDatabase.LoadAssetAtPath <Shader>(AssetDatabase.GUIDToAssetPath(assets[0]));
            }
            else
            {
                drawingShader = Shader.Find("Infinity Code/Online Maps/Tileset DrawingElement");
            }
        }
        else
        {
            defaultTilesetShader = Shader.Find("Infinity Code/Online Maps/Tileset Cutout");
            tilesetShader        = defaultTilesetShader;
            markerShader         = Shader.Find("Transparent/Diffuse");
            drawingShader        = Shader.Find("Infinity Code/Online Maps/Tileset DrawingElement");
        }


        activeCamera = Camera.main;

        CachePlugins();
        CacheControls();
        InitSteps();

        if (useSRP)
        {
            Plugin plugin = plugins.FirstOrDefault(p => p.title == "PBR Bridge") as Plugin;
            if (plugin != null)
            {
                plugin.enabled = true;
            }
        }
    }