Skip to content

Commit 07b37de

Browse files
committed
Corrected Azure raster overlay editor, added required API session fields
1 parent c6d4ddb commit 07b37de

File tree

4 files changed

+252
-45
lines changed

4 files changed

+252
-45
lines changed

Editor/CesiumAzureMapsRasterOverlayEditor.cs

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ public class CesiumAzureMapsRasterOverlayEditor : Editor
88
{
99
private CesiumRasterOverlayEditor _rasterOverlayEditor;
1010

11-
private SerializedProperty _azureMapsKey;
12-
private SerializedProperty _mapStyle;
11+
private SerializedProperty _key;
12+
private SerializedProperty _apiVersion;
13+
private SerializedProperty _tilesetId;
14+
private SerializedProperty _language;
15+
private SerializedProperty _view;
16+
1317

1418
private void OnEnable()
1519
{
@@ -18,8 +22,11 @@ private void OnEnable()
1822
this.target,
1923
typeof(CesiumRasterOverlayEditor));
2024

21-
this._azureMapsKey = this.serializedObject.FindProperty("_azureMapsKey");
22-
this._mapStyle = this.serializedObject.FindProperty("_mapStyle");
25+
this._key = this.serializedObject.FindProperty("_key");
26+
this._apiVersion = this.serializedObject.FindProperty("_apiVersion");
27+
this._tilesetId = this.serializedObject.FindProperty("_tilesetId");
28+
this._language = this.serializedObject.FindProperty("_language");
29+
this._view = this.serializedObject.FindProperty("_view");
2330
}
2431

2532
private void OnDisable()
@@ -45,15 +52,34 @@ public override void OnInspectorGUI()
4552

4653
private void DrawAzureMapsProperties()
4754
{
48-
GUIContent azureMapsKeyContent = new GUIContent(
49-
"Azure Maps Key",
50-
"The Azure Maps API key to use.");
51-
EditorGUILayout.DelayedTextField(this._azureMapsKey, azureMapsKeyContent);
52-
53-
GUIContent mapStyleContent = new GUIContent(
54-
"Map Style",
55-
"The map style to use.");
56-
EditorGUILayout.PropertyField(this._mapStyle, mapStyleContent);
55+
var keyContent = new GUIContent(
56+
"Key",
57+
"The Azure Maps key to use.");
58+
EditorGUILayout.DelayedTextField(this._key, keyContent);
59+
60+
var apiVersionContent = new GUIContent(
61+
"API Version",
62+
"The Azure Maps API version to use.");
63+
EditorGUILayout.PropertyField(this._apiVersion, apiVersionContent);
64+
65+
var tileSetIdContent = new GUIContent(
66+
"Tile Set ID",
67+
"The Azure tile set ID to use.");
68+
EditorGUILayout.PropertyField(this._tilesetId, tileSetIdContent);
69+
70+
var languageContent = new GUIContent(
71+
"Language",
72+
"The language in which search results should be returned. This should be one"
73+
+ " of the supported IETF language tags, case insensitive. When data in the"
74+
+ " specified language is not available for a specific field, default language");
75+
EditorGUILayout.PropertyField(this._language, languageContent);
76+
77+
var viewContent = new GUIContent(
78+
"View",
79+
"The View parameter (also called the \"user region\" parameter) allows"
80+
+ " you to show the correct maps for a certain country/region for"
81+
+ " geopolitically disputed regions.");
82+
EditorGUILayout.PropertyField(this._view, viewContent);
5783
}
5884

5985
private void DrawRasterOverlayProperties() => this._rasterOverlayEditor?.OnInspectorGUI();

Runtime/CesiumAzureMapsRasterOverlay.cs

Lines changed: 160 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,98 @@
11
using Reinterop;
22
using System.Collections;
33
using System.Collections.Generic;
4+
using System.ComponentModel;
45
using UnityEngine;
56

67
namespace CesiumForUnity
78
{
89
/// <summary>
910
/// The available styles of the <see cref="CesiumAzureMapsRasterOverlay"/>.
1011
/// </summary>
11-
public enum AzureMapsStyle
12+
public enum AzureMapsTilesetId
1213
{
13-
Aerial,
14-
AerialWithLabelsOnDemand,
15-
RoadOnDemand,
16-
CanvasDark,
17-
CanvasLight,
18-
CanvasGray,
19-
OrdnanceSurvey,
20-
CollinsBart
14+
/**
15+
* All roadmap layers with Azure Maps' main style.
16+
*/
17+
[Description("Base")]
18+
BaseRoad,
19+
/**
20+
* All roadmap layers with Azure Maps' dark grey style.
21+
*/
22+
[Description("Base (Dark Grey)")]
23+
BaseDarkGrey,
24+
/**
25+
* Label data in Azure Maps' main style.
26+
*/
27+
[Description("Labels")]
28+
BaseLabelsRoad,
29+
/**
30+
* Label data in Azure Maps' dark grey style.
31+
*/
32+
[Description("Labels (Dark Grey)")]
33+
BaseLabelsDarkGrey,
34+
/**
35+
* Road, boundary, and label data in Azure Maps' main style.
36+
*/
37+
[Description("Hybrid")]
38+
BaseHybridRoad,
39+
/**
40+
* Road, boundary, and label data in Azure Maps' dark grey style.
41+
*/
42+
[Description("Hybrid (Dark Grey)")]
43+
BaseHybridDarkGrey,
44+
/**
45+
* A combination of satellite or aerial imagery. Only available for accounts
46+
* under S1 and G2 pricing SKU.
47+
*/
48+
Imagery,
49+
/**
50+
* Shaded relief and terra layers.
51+
*/
52+
Terra,
53+
/**
54+
* Weather radar tiles. Latest weather radar images including areas of rain,
55+
* snow, ice and mixed conditions.
56+
*/
57+
[Description("Weather (Radar)")]
58+
WeatherRadar ,
59+
/**
60+
* Weather infrared tiles. Latest infrared satellite images showing clouds by
61+
* their temperature.
62+
*/
63+
[Description("Weather (Infrared)")]
64+
WeatherInfrared ,
65+
/**
66+
* Absolute traffic tiles in Azure Maps' main style.
67+
*/
68+
[Description("Traffic (Absolute)")]
69+
TrafficAbsolute ,
70+
/**
71+
* Relative traffic tiles in Azure Maps' main style. This filters out traffic
72+
* data from smaller streets that are otherwise included in TrafficAbsolute.
73+
*/
74+
[Description("Traffic (Relative)")]
75+
TrafficRelativeMain ,
76+
/**
77+
* Relative traffic tiles in Azure Maps' dark style. This filters out traffic
78+
* data from smaller streets that are otherwise included in TrafficAbsolute.
79+
*/
80+
[Description("Traffic (Relative, Dark)")]
81+
TrafficRelativeDark ,
82+
/**
83+
* Delay traffic tiles in Azure Maps' dark style. This only shows the points
84+
* of delay along traffic routes that are otherwise included in
85+
* TrafficAbsolute.
86+
*/
87+
[Description("Traffic (Delay)")]
88+
TrafficDelay ,
89+
/**
90+
* Reduced traffic tiles in Azure Maps' dark style. This shows the traffic
91+
* routes and major delay points, but filters out some data that is otherwise
92+
* included in TrafficAbsolute.
93+
*/
94+
[Description("Traffic (Reduced)")]
95+
TrafficReduced ,
2196
}
2297

2398
/// <summary>
@@ -32,33 +107,99 @@ public enum AzureMapsStyle
32107
public partial class CesiumAzureMapsRasterOverlay : CesiumRasterOverlay
33108
{
34109
[SerializeField]
35-
private string _azureMapsKey = "";
110+
private string _key = "";
36111

37112
/// <summary>
38-
/// The Azure Maps API key to use.
113+
/// The Azure Maps subscription key to use..
39114
/// </summary>
40-
public string azureMapsKey
115+
public string key
41116
{
42-
get => this._azureMapsKey;
117+
get => this._key;
43118
set
44119
{
45-
this._azureMapsKey = value;
120+
this._key = value;
121+
this.Refresh();
122+
}
123+
}
124+
125+
[SerializeField] private string _apiVersion = "2024-04-01";
126+
127+
/// <summary>
128+
/// The version number of Azure Maps API.
129+
/// </summary>
130+
public string apiVersion
131+
{
132+
get => this._apiVersion;
133+
set
134+
{
135+
this._apiVersion = value;
136+
this.Refresh();
137+
}
138+
}
139+
140+
[SerializeField]
141+
private AzureMapsTilesetId _tilesetId = AzureMapsTilesetId.BaseRoad;
142+
143+
/// <summary>
144+
/// The tileset ID to use.
145+
/// </summary>
146+
public AzureMapsTilesetId tilesetId
147+
{
148+
get => this._tilesetId;
149+
set
150+
{
151+
this._tilesetId = value;
152+
this.Refresh();
153+
}
154+
}
155+
156+
[SerializeField]
157+
private string _language = "en-us";
158+
159+
/// <summary>
160+
/// The language in which search results should be returned. This should be one
161+
/// of the supported IETF language tags, case insensitive. When data in the
162+
/// specified language is not available for a specific field, default language
163+
/// is used.
164+
/// </summary>
165+
public string language
166+
{
167+
get => this._language;
168+
set
169+
{
170+
this._language = value;
46171
this.Refresh();
47172
}
48173
}
49174

50175
[SerializeField]
51-
private AzureMapsStyle _mapStyle = AzureMapsStyle.Aerial;
176+
private string _view = "US";
52177

53178
/// <summary>
54-
/// The map style to use.
179+
/// The View parameter (also called the "user region" parameter) allows
180+
/// you to show the correct maps for a certain country/region for
181+
/// geopolitically disputed regions.
55182
/// </summary>
56-
public AzureMapsStyle mapStyle
183+
/// <remarks>
184+
/// Different countries/regions have different views of such regions, and the
185+
/// View parameter allows your application to comply with the view required by
186+
/// the country/region your application will be serving. By default, the View
187+
/// parameter is set to "Unified" even if you haven't defined it in the
188+
/// request. It is your responsibility to determine the location of your users,
189+
/// and then set the View parameter correctly for that location. Alternatively,
190+
/// you have the option to set 'View=Auto', which will return the map data
191+
/// based on the IP address of the request. The View parameter in Azure Maps
192+
/// must be used in compliance with applicable laws, including those regarding
193+
/// mapping, of the country/region where maps, images and other data and third
194+
/// party content that you are authorized to access via Azure Maps is made
195+
/// available. Example: view=IN.
196+
/// </remarks>
197+
public string view
57198
{
58-
get => this._mapStyle;
199+
get => this._view;
59200
set
60201
{
61-
this._mapStyle = value;
202+
this._view = value;
62203
this.Refresh();
63204
}
64205
}

Runtime/ConfigureReinterop.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ public void ExposeToCPP()
310310
overlay.maximumTextureSize = overlay.maximumTextureSize;
311311
overlay.maximumSimultaneousTileLoads = overlay.maximumSimultaneousTileLoads;
312312
overlay.subTileCacheBytes = overlay.subTileCacheBytes;
313-
313+
314314
CesiumRasterOverlay baseOverlay = ionOverlay;
315315
baseOverlay.AddToTileset();
316316
baseOverlay.RemoveFromTileset();
@@ -322,9 +322,12 @@ public void ExposeToCPP()
322322
baseOverlay = bingMapsRasterOverlay;
323323

324324
var azureMapsOverlay = go.GetComponent<CesiumAzureMapsRasterOverlay>();
325-
azureMapsOverlay.mapStyle = azureMapsOverlay.mapStyle;
326-
azureMapsOverlay.azureMapsKey = azureMapsOverlay.azureMapsKey;
327-
325+
azureMapsOverlay.key = azureMapsOverlay.key;
326+
azureMapsOverlay.apiVersion = azureMapsOverlay.apiVersion;
327+
azureMapsOverlay.tilesetId = azureMapsOverlay.tilesetId;
328+
azureMapsOverlay.language = azureMapsOverlay.language;
329+
azureMapsOverlay.view = azureMapsOverlay.view;
330+
baseOverlay = azureMapsOverlay;
328331

329332
CesiumGoogleMapTilesRasterOverlay googleMapTilesRasterOverlay =
330333
go.GetComponent<CesiumGoogleMapTilesRasterOverlay>();
@@ -342,6 +345,7 @@ public void ExposeToCPP()
342345
List<GoogleMapTilesLayerType> layers = new List<GoogleMapTilesLayerType>();
343346
if (layers.Count > 0)
344347
layers[0] = layers[0];
348+
345349

346350
CesiumTileMapServiceRasterOverlay tileMapServiceRasterOverlay =
347351
go.GetComponent<CesiumTileMapServiceRasterOverlay>();
@@ -971,7 +975,4 @@ Cesium3DTilesetLoadFailureDetails tilesetDetails
971975
var message = exception.Message;
972976
}
973977
}
974-
}
975-
976-
977-
978+
}

0 commit comments

Comments
 (0)