Skip to content

Commit 8b50583

Browse files
authored
Merge pull request #619 from CesiumGS/azure-overlay
Azure overlay
2 parents a6d1e31 + 45152db commit 8b50583

15 files changed

+522
-19
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Added `CesiumGoogleMapTilesRasterOverlay` to stream imagery from Google Maps.
88
- Added `assetOptions` to `CesiumIonRasterOverlay` to pass JSON-string options to Cesium ion as it accesses an asset.
9+
- Added `CesiumAzureMapsRasterOverlay` to stream imagery from Microsoft Azure.
910

1011
## v1.18.1 - 2025-10-01
1112

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace CesiumForUnity
5+
{
6+
[CustomEditor(typeof(CesiumAzureMapsRasterOverlay))]
7+
public class CesiumAzureMapsRasterOverlayEditor : Editor
8+
{
9+
private CesiumRasterOverlayEditor _rasterOverlayEditor;
10+
11+
private SerializedProperty _key;
12+
private SerializedProperty _apiVersion;
13+
private SerializedProperty _tilesetId;
14+
private SerializedProperty _language;
15+
private SerializedProperty _view;
16+
17+
private void OnEnable()
18+
{
19+
this._rasterOverlayEditor =
20+
(CesiumRasterOverlayEditor)Editor.CreateEditor(
21+
this.target,
22+
typeof(CesiumRasterOverlayEditor));
23+
24+
this._key = this.serializedObject.FindProperty("_key");
25+
this._apiVersion = this.serializedObject.FindProperty("_apiVersion");
26+
this._tilesetId = this.serializedObject.FindProperty("_tilesetId");
27+
this._language = this.serializedObject.FindProperty("_language");
28+
this._view = this.serializedObject.FindProperty("_view");
29+
}
30+
31+
private void OnDisable()
32+
{
33+
if (this._rasterOverlayEditor != null)
34+
{
35+
DestroyImmediate(this._rasterOverlayEditor);
36+
}
37+
}
38+
39+
public override void OnInspectorGUI()
40+
{
41+
this.serializedObject.Update();
42+
this._rasterOverlayEditor?.DrawInspectorButtons();
43+
EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth;
44+
this.DrawAzureMapsProperties();
45+
EditorGUILayout.Space(5);
46+
this.DrawRasterOverlayProperties();
47+
this.serializedObject.ApplyModifiedProperties();
48+
}
49+
50+
private void DrawAzureMapsProperties()
51+
{
52+
var keyContent = new GUIContent(
53+
"Key",
54+
"The Azure Maps key to use.");
55+
EditorGUILayout.DelayedTextField(this._key, keyContent);
56+
57+
var apiVersionContent = new GUIContent(
58+
"API Version",
59+
"The Azure Maps API version to use.");
60+
EditorGUILayout.PropertyField(this._apiVersion, apiVersionContent);
61+
62+
var tileSetIdContent = new GUIContent(
63+
"Tile Set ID",
64+
"The Azure tile set ID to use.");
65+
EditorGUILayout.PropertyField(this._tilesetId, tileSetIdContent);
66+
67+
var languageContent = new GUIContent(
68+
"Language",
69+
"The language in which search results should be returned. This should be one"
70+
+ " of the supported IETF language tags, case insensitive. When data in the"
71+
+ " specified language is not available for a specific field, default language");
72+
EditorGUILayout.PropertyField(this._language, languageContent);
73+
74+
var viewContent = new GUIContent(
75+
"View",
76+
"The View parameter (also called the \"user region\" parameter) allows "
77+
+"you to show the correct maps for a certain country/region for "
78+
+"geopolitically disputed regions. "
79+
+"\n"
80+
+"Different countries/regions have different views of such regions, and the "
81+
+"View parameter allows your application to comply with the view required by "
82+
+"the country/region your application will be serving. By default, the View "
83+
+"parameter is set to \"Unified\" even if you haven't defined it in the "
84+
+"request. It is your responsibility to determine the location of your users, "
85+
+"and then set the View parameter correctly for that location. Alternatively, "
86+
+"you have the option to set 'View=Auto', which will return the map data "
87+
+"based on the IP address of the request. The View parameter in Azure Maps "
88+
+"must be used in compliance with applicable laws, including those regarding "
89+
+"mapping, of the country/region where maps, images and other data and third "
90+
+"party content that you are authorized to access via Azure Maps is made "
91+
+"available. Example: view=IN.");
92+
EditorGUILayout.PropertyField(this._view, viewContent);
93+
}
94+
95+
private void DrawRasterOverlayProperties() => this._rasterOverlayEditor?.OnInspectorGUI();
96+
}
97+
}

Editor/CesiumAzureMapsRasterOverlayEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/CesiumBingMapsRasterOverlayEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private void OnDisable()
3333
public override void OnInspectorGUI()
3434
{
3535
this.serializedObject.Update();
36+
this._rasterOverlayEditor?.DrawInspectorButtons();
3637

3738
EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth;
3839
this.DrawBingMapsProperties();

Editor/CesiumGoogleMapTilesRasterOverlayEditor.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private void OnDisable()
5959
public override void OnInspectorGUI()
6060
{
6161
this.serializedObject.Update();
62-
62+
this._rasterOverlayEditor?.DrawInspectorButtons();
6363
EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth;
6464
this.DrawGoogleMapTilesProperties();
6565
EditorGUILayout.Space(5);
@@ -157,10 +157,7 @@ private void DrawGoogleMapTilesProperties()
157157

158158
private void DrawRasterOverlayProperties()
159159
{
160-
if (this._rasterOverlayEditor != null)
161-
{
162-
this._rasterOverlayEditor.OnInspectorGUI();
163-
}
160+
this._rasterOverlayEditor?.OnInspectorGUI();
164161
}
165162
}
166163
}

Editor/CesiumIonRasterOverlayEditor.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public override void OnInspectorGUI()
4141
this.serializedObject.Update();
4242

4343
EditorGUIUtility.labelWidth = CesiumEditorStyle.inspectorLabelWidth;
44-
DrawTroubleshootButton();
44+
DrawInspectorButtons();
4545
EditorGUILayout.Space(5);
4646
DrawIonProperties();
4747
EditorGUILayout.Space(5);
@@ -50,16 +50,25 @@ public override void OnInspectorGUI()
5050
this.serializedObject.ApplyModifiedProperties();
5151
}
5252

53-
private void DrawTroubleshootButton()
53+
private void DrawInspectorButtons()
5454
{
55-
GUIContent troubleshootTokenContent = new GUIContent(
55+
GUILayout.BeginHorizontal();
56+
var refreshOverlayContent = new GUIContent("Refresh Overlay",
57+
"Refreshes this overlay.");
58+
if (GUILayout.Button(refreshOverlayContent))
59+
{
60+
this._ionOverlay.Refresh();
61+
}
62+
63+
var troubleshootTokenContent = new GUIContent(
5664
"Troubleshoot Token",
5765
"Check if the Cesium ion token used to access this raster overlay is working " +
5866
"correctly, and fix it if necessary.");
5967
if (GUILayout.Button(troubleshootTokenContent))
6068
{
6169
IonTokenTroubleshootingWindow.ShowWindow(this._ionOverlay, false);
6270
}
71+
GUILayout.EndHorizontal();
6372
}
6473

6574
private void DrawIonProperties()

Editor/CesiumRasterOverlayEditor.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ private void OnEnable()
4444
this._materialKeys = new string[] { };
4545
}
4646

47+
public void DrawInspectorButtons()
48+
{
49+
var refreshOverlayContent = new GUIContent("Refresh Overlay",
50+
"Refreshes this overlay.");
51+
if (GUILayout.Button(refreshOverlayContent))
52+
{
53+
this._overlay?.Refresh();
54+
}
55+
}
56+
4757
public override void OnInspectorGUI()
4858
{
4959
this.serializedObject.Update();

Editor/ConfigureReinterop.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using UnityEngine;
1010
using UnityEngine.Networking;
1111

12+
1213
namespace CesiumForUnity
1314
{
1415
[Reinterop]
@@ -62,12 +63,13 @@ public void ExposeToCPP()
6263
string e = request.error;
6364
string method = request.method;
6465
string url = request.url;
65-
if (request.result == UnityWebRequest.Result.Success) { };
66+
if (request.result == UnityWebRequest.Result.Success) { }
67+
;
6668
request.downloadHandler = new NativeDownloadHandler();
6769
request.SetRequestHeader("name", "value");
6870
request.GetResponseHeader("name");
69-
Dictionary<string,string>.Enumerator enumerator = request.GetResponseHeaders().GetEnumerator();
70-
while(enumerator.MoveNext())
71+
Dictionary<string, string>.Enumerator enumerator = request.GetResponseHeaders().GetEnumerator();
72+
while (enumerator.MoveNext())
7173
{
7274
string key = enumerator.Current.Key;
7375
string value = enumerator.Current.Value;
@@ -100,7 +102,7 @@ public void ExposeToCPP()
100102

101103
item = new QuickAddItem(QuickAddItemType.IonTileset, "name", "tooltip", "tilesetName", 1, "overlayName", 2);
102104
items.Add(item);
103-
105+
104106
server.defaultIonAccessToken = "";
105107
server.defaultIonAccessTokenId = "";
106108
server.apiUrl = "";
@@ -253,3 +255,4 @@ public void ExposeToCPP()
253255
}
254256
}
255257
}
258+

0 commit comments

Comments
 (0)