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"; }
private void DrawProvider(ref bool allowCreate) { EditorGUI.BeginChangeCheck(); providerIndex = EditorGUILayout.Popup("Provider", providerIndex, providersTitle); if (EditorGUI.EndChangeCheck()) { activeMapType = providers[providerIndex].types[0]; } if (activeMapType.isCustom) { 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(); } }
private void DrawProviderGUI() { EditorGUI.BeginChangeCheck(); providerIndex = EditorGUILayout.Popup("Provider", providerIndex, providersTitle); if (EditorGUI.EndChangeCheck()) { mapType = providers[providerIndex].types[0]; pMapType.stringValue = mapType.ToString(); } if (mapType.useHTTP) { EditorGUILayout.HelpBox(mapType.provider.title + " - " + mapType.title + " uses HTTP, which can cause problems in iOS9+.", MessageType.Warning); } else if (mapType.isCustom) { EditorGUILayout.PropertyField(pCustomProviderURL); EditorGUILayout.BeginVertical(GUI.skin.box); showCustomProviderTokens = Foldout(showCustomProviderTokens, "Available tokens"); if (showCustomProviderTokens) { GUILayout.Label("{zoom}"); GUILayout.Label("{x}"); GUILayout.Label("{y}"); GUILayout.Label("{quad}"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); } }
private void DrawSource(ref bool allowCreate) { source = (OnlineMapsSource)EditorGUILayout.EnumPopup("Source: ", source); if (source != OnlineMapsSource.Resources) { webplayerProxyURL = EditorGUILayout.TextField("Proxy (for Webplayer): ", webplayerProxyURL); DrawProvider(ref allowCreate); GUIContent[] aviableTypes = activeMapType.provider.types.Select(t => new GUIContent(t.title)).ToArray(); if (aviableTypes != null) { int index = activeMapType.index; EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup(new GUIContent("Type: ", "Type of map texture"), index, aviableTypes); if (EditorGUI.EndChangeCheck()) { activeMapType = activeMapType.provider.types[index]; } } DrawLabels(); } }
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"); }
private void DrawMapTypes(ref bool dirty) { if (control != null && !control.useRasterTiles) { return; } if (pSource.enumValueIndex == (int)OnlineMapsSource.Resources) { return; } DrawProviderGUI(); if (mapType.provider.types.Length > 1) { GUIContent[] availableTypes = mapType.provider.types.Select(t => new GUIContent(t.title)).ToArray(); int index = mapType.index; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup(new GUIContent("Type", "Type of map texture"), index, availableTypes); if (EditorGUI.EndChangeCheck()) { mapType = mapType.provider.types[index]; pMapType.stringValue = mapType.ToString(); } OnlineMapsEditorUtils.HelpButton("Type (style) of the map"); EditorGUILayout.EndHorizontal(); } DrawProviderExtraFields(ref dirty, mapType.provider.extraFields); DrawProviderExtraFields(ref dirty, mapType.extraFields); DrawLabelsGUI(); }
/// <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"; } } }
public OnlineMapsRasterTile(int x, int y, int zoom, OnlineMaps map, bool isMapTile = true) : base(x, y, zoom, map, isMapTile) { _trafficProvider = map.trafficProvider; mapType = map.activeType; labels = map.labels; language = map.language; }
public static void OpenWindow() { GetWindow <OnlineMapsWizard>(true, "Create Map", true); activeMapType = OnlineMapsProvider.FindMapType("arcgis"); providers = OnlineMapsProvider.GetProviders(); providersTitle = OnlineMapsProvider.GetProvidersTitle(); providerIndex = activeMapType.provider.index; }
public OnlineMapsTile(int x, int y, int zoom, OnlineMaps map, bool isMapTile = true) { if (unusedTiles == null) { unusedTiles = new List <OnlineMapsTile>(); } 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.map = map; this.isMapTile = isMapTile; mapType = map.activeType; _trafficProvider = map.trafficProvider; labels = map.labels; language = map.language; double tlx, tly, brx, bry; map.projection.TileToCoordinates(x, y, zoom, out tlx, out tly); map.projection.TileToCoordinates(x + 1, y + 1, zoom, out brx, out bry); topLeft = new Vector2((float)tlx, (float)tly); bottomRight = new Vector2((float)brx, (float)bry); globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f); key = GetTileKey(zoom, x, y); if (isMapTile) { tiles.Add(this); if (dTiles.ContainsKey(key)) { dTiles[key] = this; } else { dTiles.Add(key, this); } } }
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; }
public OnlineMapsTile(int x, int y, int zoom, OnlineMaps api, bool isMapTile = true) { if (unusedTiles == null) { unusedTiles = new List <OnlineMapsTile>(); } 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; mapType = api.activeType; labels = api.labels; language = api.language; double tlx, tly, brx, bry; api.projection.TileToCoordinates(x, y, zoom, out tlx, out tly); api.projection.TileToCoordinates(x + 1, y + 1, zoom, out brx, out bry); topLeft = new Vector2((float)tlx, (float)tly); bottomRight = new Vector2((float)brx, (float)bry); globalPosition = Vector2.Lerp(topLeft, bottomRight, 0.5f); StringBuilder builder = new StringBuilder(); builder.AppendFormat("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); trafficURL = builder.ToString(); if (isMapTile) { tiles.Add(this); } }
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; } }
private void DrawProviderGUI() { EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); providerIndex = EditorGUILayout.Popup("Provider", providerIndex, providersTitle); if (EditorGUI.EndChangeCheck()) { mapType = providers[providerIndex].types[0]; pMapType.stringValue = mapType.ToString(); pActiveTypeSettings.stringValue = ""; } OnlineMapsEditorUtils.HelpButton("Tile provider.\nImportant: all tile presets are for testing purpose only. Before using the tile provider, make sure that it suits you by the terms of use and price."); EditorGUILayout.EndHorizontal(); if (mapType.useHTTP) { EditorGUILayout.HelpBox(mapType.provider.title + " - " + mapType.title + " uses HTTP, which can cause problems in iOS9+.", MessageType.Warning); } else if (mapType.isCustom) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); GUILayout.Space(5); EditorGUILayout.PropertyField(pCustomProviderURL); EditorGUILayout.EndVertical(); if (GUILayout.Button(wizardIconContent, GUILayout.ExpandWidth(false))) { OnlineMapsCustomURLWizard.OpenWindow(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(GUI.skin.box); showCustomProviderTokens = Foldout(showCustomProviderTokens, "Available tokens"); if (showCustomProviderTokens) { GUILayout.Label("{zoom}"); GUILayout.Label("{x}"); GUILayout.Label("{y}"); GUILayout.Label("{quad}"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); } }
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(); }
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(); }
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; } } }
private void DrawMapTypes(ref bool dirty) { if (control != null && !control.useRasterTiles) { return; } if (pSource.enumValueIndex == (int)OnlineMapsSource.Resources) { return; } if (pSource.enumValueIndex == (int)OnlineMapsSource.StreamingAssets) { return; } DrawProviderGUI(); if (mapType.provider.types.Length > 1) { GUIContent[] availableTypes = mapType.provider.types.Select(t => new GUIContent(t.title)).ToArray(); int index = mapType.index; EditorGUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup(new GUIContent("Type", "Type of map texture"), index, availableTypes); if (EditorGUI.EndChangeCheck()) { mapType = mapType.provider.types[index]; pMapType.stringValue = mapType.ToString(); } OnlineMapsEditorUtils.HelpButton("Type (style) of the map"); EditorGUILayout.EndHorizontal(); } DrawProviderExtraFields(ref dirty, mapType.provider.extraFields); DrawProviderExtraFields(ref dirty, mapType.extraFields); if (mapType.fullID == "google.satellite") { if (GUILayout.Button("Detect the latest version of tiles")) { WebClient client = new WebClient(); string response = client.DownloadString("http://maps.googleapis.com/maps/api/js"); Match match = Regex.Match(response, @"kh\?v=(\d+)"); if (match.Success) { OnlineMapsProvider.ExtraField version = mapType.extraFields.FirstOrDefault(f => { OnlineMapsProvider.ExtraField ef = f as OnlineMapsProvider.ExtraField; if (ef == null) { return(false); } if (ef.token != "version") { return(false); } return(true); }) as OnlineMapsProvider.ExtraField; if (version != null) { version.value = match.Groups[1].Value; } } } } DrawLabelsGUI(); }
private void DrawSourceGUI() { EditorGUI.BeginDisabledGroup(isPlay); EditorGUILayout.PropertyField(pSource); #if UNITY_WEBPLAYER || UNITY_WEBGL if (pSource.enumValueIndex != (int)OnlineMapsSource.Resources) { EditorGUILayout.PropertyField(pUseProxy, new GUIContent("Use Proxy")); EditorGUI.BeginDisabledGroup(!pUseProxy.boolValue); EditorGUILayout.PropertyField(pWebplayerProxyURL, new GUIContent("Proxy")); EditorGUI.EndDisabledGroup(); } #endif if (pSource.enumValueIndex != (int)OnlineMapsSource.Online) { if (GUILayout.Button("Fix Import Settings for Tiles")) { FixImportSettings(); } if (GUILayout.Button("Import from GMapCatcher")) { ImportFromGMapCatcher(); } EditorGUILayout.PropertyField(pResourcesPath); EditorGUILayout.BeginVertical(GUI.skin.box); showResourcesTokens = Foldout(showResourcesTokens, "Available Tokens"); if (showResourcesTokens) { GUILayout.Label("{zoom}"); GUILayout.Label("{x}"); GUILayout.Label("{y}"); GUILayout.Label("{quad}"); GUILayout.Space(10); } EditorGUILayout.EndVertical(); } EditorGUI.EndDisabledGroup(); if (pSource.enumValueIndex != (int)OnlineMapsSource.Resources) { DrawProviderGUI(); if (mapType.provider.types.Length > 1) { GUIContent[] availableTypes = mapType.provider.types.Select(t => new GUIContent(t.title)).ToArray(); int index = mapType.index; EditorGUI.BeginChangeCheck(); index = EditorGUILayout.Popup(new GUIContent("Type", "Type of map texture"), index, availableTypes); if (EditorGUI.EndChangeCheck()) { mapType = mapType.provider.types[index]; pMapType.stringValue = mapType.ToString(); } } DrawProviderExtraFields(); DrawLabelsGUI(); } }