[TASK] Initial commit with basic product setup
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="DirectionsExample.cs" company="Mapbox">
|
||||
// Copyright (c) 2016 Mapbox. All rights reserved.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Mapbox.Examples.Playground
|
||||
{
|
||||
using Mapbox.Unity;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Mapbox.Json;
|
||||
using Mapbox.Directions;
|
||||
using Mapbox.Utils;
|
||||
using Mapbox.Utils.JsonConverters;
|
||||
using Mapbox.Geocoding;
|
||||
|
||||
/// <summary>
|
||||
/// Fetch directions JSON once start and end locations are provided.
|
||||
/// Example: Enter Start Location: San Francisco, Enter Destination: Los Angeles
|
||||
/// </summary>
|
||||
public class DirectionsExample : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
Text _resultsText;
|
||||
|
||||
[SerializeField]
|
||||
ForwardGeocodeUserInput _startLocationGeocoder;
|
||||
|
||||
[SerializeField]
|
||||
ForwardGeocodeUserInput _endLocationGeocoder;
|
||||
|
||||
Directions _directions;
|
||||
|
||||
Vector2d[] _coordinates;
|
||||
|
||||
DirectionResource _directionResource;
|
||||
|
||||
void Start()
|
||||
{
|
||||
_directions = MapboxAccess.Instance.Directions;
|
||||
_startLocationGeocoder.OnGeocoderResponse += StartLocationGeocoder_OnGeocoderResponse;
|
||||
_endLocationGeocoder.OnGeocoderResponse += EndLocationGeocoder_OnGeocoderResponse;
|
||||
|
||||
_coordinates = new Vector2d[2];
|
||||
|
||||
// Can we make routing profiles an enum?
|
||||
_directionResource = new DirectionResource(_coordinates, RoutingProfile.Driving);
|
||||
_directionResource.Steps = true;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_startLocationGeocoder != null)
|
||||
{
|
||||
_startLocationGeocoder.OnGeocoderResponse -= StartLocationGeocoder_OnGeocoderResponse;
|
||||
}
|
||||
|
||||
if (_startLocationGeocoder != null)
|
||||
{
|
||||
_startLocationGeocoder.OnGeocoderResponse -= EndLocationGeocoder_OnGeocoderResponse;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start location geocoder responded, update start coordinates.
|
||||
/// </summary>
|
||||
/// <param name="sender">Sender.</param>
|
||||
/// <param name="e">E.</param>
|
||||
void StartLocationGeocoder_OnGeocoderResponse(ForwardGeocodeResponse response)
|
||||
{
|
||||
_coordinates[0] = _startLocationGeocoder.Coordinate;
|
||||
if (ShouldRoute())
|
||||
{
|
||||
Route();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// End location geocoder responded, update end coordinates.
|
||||
/// </summary>
|
||||
/// <param name="sender">Sender.</param>
|
||||
/// <param name="e">E.</param>
|
||||
void EndLocationGeocoder_OnGeocoderResponse(ForwardGeocodeResponse response)
|
||||
{
|
||||
_coordinates[1] = _endLocationGeocoder.Coordinate;
|
||||
if (ShouldRoute())
|
||||
{
|
||||
Route();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure both forward geocoders have a response, which grants access to their respective coordinates.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if both forward geocoders have a response, <c>false</c> otherwise.</returns>
|
||||
bool ShouldRoute()
|
||||
{
|
||||
return _startLocationGeocoder.HasResponse && _endLocationGeocoder.HasResponse;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Route
|
||||
/// </summary>
|
||||
void Route()
|
||||
{
|
||||
_directionResource.Coordinates = _coordinates;
|
||||
_directions.Query(_directionResource, HandleDirectionsResponse);
|
||||
}
|
||||
/// <summary>
|
||||
/// Log directions response to UI.
|
||||
/// </summary>
|
||||
/// <param name="res">Res.</param>
|
||||
void HandleDirectionsResponse(DirectionsResponse res)
|
||||
{
|
||||
var data = JsonConvert.SerializeObject(res, Formatting.Indented, JsonConverters.Converters);
|
||||
string sub = data.Substring(0, data.Length > 5000 ? 5000 : data.Length) + "\n. . . ";
|
||||
_resultsText.text = sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6813623cf588043fa958028235282143
|
||||
timeCreated: 1480366119
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ForwardGeocoderExample.cs" company="Mapbox">
|
||||
// Copyright (c) 2016 Mapbox. All rights reserved.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Mapbox.Examples.Playground
|
||||
{
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Mapbox.Json;
|
||||
using Mapbox.Utils.JsonConverters;
|
||||
using Mapbox.Geocoding;
|
||||
|
||||
public class ForwardGeocoderExample : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
ForwardGeocodeUserInput _searchLocation;
|
||||
|
||||
[SerializeField]
|
||||
Text _resultsText;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse += SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_searchLocation != null)
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse -= SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchLocation_OnGeocoderResponse(ForwardGeocodeResponse response)
|
||||
{
|
||||
_resultsText.text = JsonConvert.SerializeObject(_searchLocation.Response, Formatting.Indented, JsonConverters.Converters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9db62c5c7a8e7409e99e6cb401d74611
|
||||
timeCreated: 1480379354
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
namespace Mapbox.Examples.Scripts
|
||||
{
|
||||
using Mapbox.Unity.Location;
|
||||
using Mapbox.Utils;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LogLocationProviderData : MonoBehaviour
|
||||
{
|
||||
|
||||
[SerializeField]
|
||||
private Text _logText;
|
||||
|
||||
[SerializeField]
|
||||
private Toggle _logToggle;
|
||||
|
||||
|
||||
private CultureInfo _invariantCulture = CultureInfo.InvariantCulture;
|
||||
private bool _logToFile = false;
|
||||
private LocationLogWriter _logWriter = null;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
||||
LocationProviderFactory.Instance.DefaultLocationProvider.OnLocationUpdated += LocationProvider_OnLocationUpdated;
|
||||
|
||||
if (null != _logToggle)
|
||||
{
|
||||
_logToggle.onValueChanged.AddListener((isOn) => { _logToFile = isOn; });
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("no logtoggle attached, cannot log");
|
||||
}
|
||||
if (null == _logText)
|
||||
{
|
||||
Debug.LogError("no text to log to");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
closeLogWriter();
|
||||
LocationProviderFactory.Instance.DefaultLocationProvider.OnLocationUpdated -= LocationProvider_OnLocationUpdated;
|
||||
}
|
||||
|
||||
|
||||
void LocationProvider_OnLocationUpdated(Location location)
|
||||
{
|
||||
|
||||
/////////////// GUI logging //////////////////////
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine(string.Format("IsLocationServiceEnabled: {0}", location.IsLocationServiceEnabled));
|
||||
sb.AppendLine(string.Format("IsLocationServiceInitializing: {0}", location.IsLocationServiceInitializing));
|
||||
sb.AppendLine(string.Format("IsLocationUpdated: {0}", location.IsLocationUpdated));
|
||||
sb.AppendLine(string.Format("IsHeadingUpdated: {0}", location.IsUserHeadingUpdated));
|
||||
string locationProviderClass = LocationProviderFactory.Instance.DefaultLocationProvider.GetType().Name;
|
||||
sb.AppendLine(string.Format("location provider: {0} ({1})", location.Provider, locationProviderClass));
|
||||
sb.AppendLine(string.Format("UTC time:{0} - device: {1}{0} - location:{2}", Environment.NewLine, DateTime.UtcNow.ToString("yyyyMMdd HHmmss"), UnixTimestampUtils.From(location.Timestamp).ToString("yyyyMMdd HHmmss")));
|
||||
sb.AppendLine(string.Format(_invariantCulture, "position: {0:0.00000000} / {1:0.00000000}", location.LatitudeLongitude.x, location.LatitudeLongitude.y));
|
||||
sb.AppendLine(string.Format(_invariantCulture, "accuracy: {0:0.0}m", location.Accuracy));
|
||||
sb.AppendLine(string.Format(_invariantCulture, "user heading: {0:0.0}°", location.UserHeading));
|
||||
sb.AppendLine(string.Format(_invariantCulture, "device orientation: {0:0.0}°", location.DeviceOrientation));
|
||||
sb.AppendLine(nullableAsStr<float>(location.SpeedKmPerHour, "speed: {0:0.0}km/h"));
|
||||
sb.AppendLine(nullableAsStr<bool>(location.HasGpsFix, "HasGpsFix: {0}"));
|
||||
sb.AppendLine(nullableAsStr<int>(location.SatellitesUsed, "SatellitesUsed:{0} "));
|
||||
sb.AppendLine(nullableAsStr<int>(location.SatellitesInView, "SatellitesInView:{0}"));
|
||||
|
||||
if (null != _logText)
|
||||
{
|
||||
_logText.text = sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
/////////////// file logging //////////////////////
|
||||
|
||||
// start logging to file
|
||||
if (_logToFile && null == _logWriter)
|
||||
{
|
||||
Debug.Log("--- about to start logging to file ---");
|
||||
_logWriter = new LocationLogWriter();
|
||||
_logToggle.GetComponentInChildren<Text>().text = "stop logging";
|
||||
}
|
||||
|
||||
|
||||
// stop logging to file
|
||||
if (!_logToFile && null != _logWriter)
|
||||
{
|
||||
Debug.Log("--- about to stop logging to file ---");
|
||||
_logToggle.GetComponentInChildren<Text>().text = "start logging";
|
||||
closeLogWriter();
|
||||
}
|
||||
|
||||
|
||||
// write line to log file
|
||||
if (_logToFile && null != _logWriter)
|
||||
{
|
||||
_logWriter.Write(location);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private string nullableAsStr<T>(T? val, string formatString = null) where T : struct
|
||||
{
|
||||
if (null == val && null == formatString) { return "[not supported by provider]"; }
|
||||
if (null == val && null != formatString) { return string.Format(_invariantCulture, formatString, "[not supported by provider]"); }
|
||||
if (null != val && null == formatString) { return val.Value.ToString(); }
|
||||
return string.Format(_invariantCulture, formatString, val);
|
||||
}
|
||||
|
||||
|
||||
private void closeLogWriter()
|
||||
{
|
||||
if (null == _logWriter) { return; }
|
||||
Debug.Log("closing stream writer");
|
||||
_logWriter.Dispose();
|
||||
_logWriter = null;
|
||||
}
|
||||
|
||||
|
||||
void Update() { }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1e59fc6e7b8a20469944d48968f397f
|
||||
timeCreated: 1524490509
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,136 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="RasterTileExample.cs" company="Mapbox">
|
||||
// Copyright (c) 2016 Mapbox. All rights reserved.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Mapbox.Examples.Playground
|
||||
{
|
||||
using System.Linq;
|
||||
using System;
|
||||
using Mapbox.Map;
|
||||
using Mapbox.Unity;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Mapbox.Utils;
|
||||
using Mapbox.Unity.Utilities;
|
||||
using Mapbox.Geocoding;
|
||||
|
||||
public class RasterTileExample : MonoBehaviour, Mapbox.Utils.IObserver<RasterTile>
|
||||
{
|
||||
[SerializeField]
|
||||
ForwardGeocodeUserInput _searchLocation;
|
||||
|
||||
[SerializeField]
|
||||
Slider _zoomSlider;
|
||||
|
||||
[SerializeField]
|
||||
Dropdown _stylesDropdown;
|
||||
|
||||
[SerializeField]
|
||||
RawImage _imageContainer;
|
||||
|
||||
Map<RasterTile> _map;
|
||||
|
||||
[Geocode]
|
||||
[SerializeField]
|
||||
string _latLon;
|
||||
|
||||
// initialize _mapboxStyles
|
||||
string[] _mapboxStyles = new string[]
|
||||
{
|
||||
"mapbox://styles/mapbox/satellite-v9",
|
||||
"mapbox://styles/mapbox/streets-v9",
|
||||
"mapbox://styles/mapbox/dark-v9",
|
||||
"mapbox://styles/mapbox/light-v9"
|
||||
};
|
||||
|
||||
// start location - San Francisco
|
||||
Vector2d _startLoc = new Vector2d();
|
||||
|
||||
int _mapstyle = 0;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse += SearchLocation_OnGeocoderResponse;
|
||||
_stylesDropdown.ClearOptions();
|
||||
_stylesDropdown.AddOptions(_mapboxStyles.ToList());
|
||||
_stylesDropdown.onValueChanged.AddListener(ToggleDropdownStyles);
|
||||
_zoomSlider.onValueChanged.AddListener(AdjustZoom);
|
||||
|
||||
var parsed = _latLon.Split(',');
|
||||
_startLoc.x = double.Parse(parsed[0]);
|
||||
_startLoc.y = double.Parse(parsed[1]);
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_searchLocation != null)
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse -= SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_map = new Map<RasterTile>(MapboxAccess.Instance);
|
||||
_map.MapId = _mapboxStyles[_mapstyle];
|
||||
_map.Center = _startLoc;
|
||||
_map.Zoom = (int)_zoomSlider.value;
|
||||
_map.Subscribe(this);
|
||||
_map.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// New search location has become available, begin a new _map query.
|
||||
/// </summary>
|
||||
/// <param name="sender">Sender.</param>
|
||||
/// <param name="e">E.</param>
|
||||
void SearchLocation_OnGeocoderResponse(ForwardGeocodeResponse response)
|
||||
{
|
||||
_map.Center = _searchLocation.Coordinate;
|
||||
_map.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zoom was modified by the slider, begin a new _map query.
|
||||
/// </summary>
|
||||
/// <param name="value">Value.</param>
|
||||
void AdjustZoom(float value)
|
||||
{
|
||||
_map.Zoom = (int)_zoomSlider.value;
|
||||
_map.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Style dropdown updated, begin a new _map query.
|
||||
/// </summary>
|
||||
/// <param name="value">If set to <c>true</c> value.</param>
|
||||
void ToggleDropdownStyles(int target)
|
||||
{
|
||||
_mapstyle = target;
|
||||
_map.MapId = _mapboxStyles[target];
|
||||
_map.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the texture with new data.
|
||||
/// </summary>
|
||||
/// <param name="tile">Tile.</param>
|
||||
public void OnNext(RasterTile tile)
|
||||
{
|
||||
if (
|
||||
tile.HasError
|
||||
|| (tile.CurrentState != Tile.State.Loaded && tile.CurrentState != Tile.State.Updated)
|
||||
)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Can we utility this? Should users have to know source size?
|
||||
var texture = new Texture2D(256, 256);
|
||||
texture.LoadImage(tile.Data);
|
||||
_imageContainer.texture = texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: baa72cd3a86b44e2e9923f1bfb635675
|
||||
timeCreated: 1480376499
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="ForwardGeocoderExample.cs" company="Mapbox">
|
||||
// Copyright (c) 2016 Mapbox. All rights reserved.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
namespace Mapbox.Examples.Playground
|
||||
{
|
||||
using Mapbox.Json;
|
||||
using Mapbox.Utils.JsonConverters;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ReverseGeocoderExample : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
ReverseGeocodeUserInput _searchLocation;
|
||||
|
||||
[SerializeField]
|
||||
Text _resultsText;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse += SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_searchLocation != null)
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse -= SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
}
|
||||
|
||||
void SearchLocation_OnGeocoderResponse(object sender, System.EventArgs e)
|
||||
{
|
||||
_resultsText.text = JsonConvert.SerializeObject(_searchLocation.Response, Formatting.Indented, JsonConverters.Converters);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d99f8e76925b24aaeaa5f9e5e23f3085
|
||||
timeCreated: 1480379354
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,98 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="VectorTileExample.cs" company="Mapbox">
|
||||
// Copyright (c) 2016 Mapbox. All rights reserved.
|
||||
// </copyright>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace Mapbox.Examples.Playground
|
||||
{
|
||||
using Mapbox.Unity;
|
||||
using Mapbox.Platform;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Mapbox.Map;
|
||||
using Mapbox.Json;
|
||||
using Mapbox.VectorTile.ExtensionMethods;
|
||||
using Mapbox.Utils.JsonConverters;
|
||||
using Mapbox.Geocoding;
|
||||
|
||||
public class VectorTileExample : MonoBehaviour, Mapbox.Utils.IObserver<VectorTile>
|
||||
{
|
||||
[SerializeField]
|
||||
ForwardGeocodeUserInput _searchLocation;
|
||||
|
||||
[SerializeField]
|
||||
Text _resultsText;
|
||||
|
||||
Map<VectorTile> _map;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse += SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (_searchLocation != null)
|
||||
{
|
||||
_searchLocation.OnGeocoderResponse -= SearchLocation_OnGeocoderResponse;
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
_map = new Map<VectorTile>(new FileSource(MapboxAccess.Instance.Configuration.AccessToken));
|
||||
_map.Zoom = 18;
|
||||
// This marks us an an observer to map.
|
||||
// We will get each tile in OnNext(VectorTile tile) as they become available.
|
||||
_map.Subscribe(this);
|
||||
_map.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Search location was changed.
|
||||
/// </summary>
|
||||
/// <param name="sender">Sender.</param>
|
||||
/// <param name="e">E.</param>
|
||||
void SearchLocation_OnGeocoderResponse(ForwardGeocodeResponse response)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request _map to update its tile data with new coordinates.
|
||||
/// </summary>
|
||||
void Redraw()
|
||||
{
|
||||
if (!_searchLocation.HasResponse)
|
||||
{
|
||||
_resultsText.text = "no results";
|
||||
return;
|
||||
}
|
||||
|
||||
//zoom in to get results for consecutive searches
|
||||
_map.Center = _searchLocation.Coordinate;
|
||||
_map.Update();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle tile data from _map as they become available.
|
||||
/// </summary>
|
||||
/// <param name="tile">Tile.</param>
|
||||
public void OnNext(VectorTile tile)
|
||||
{
|
||||
if (tile.CurrentState != Tile.State.Loaded || tile.HasError)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var data = JsonConvert.SerializeObject(
|
||||
tile.Data.ToGeoJson((ulong)tile.Id.Z, (ulong)tile.Id.X, (ulong)tile.Id.Y),
|
||||
Formatting.Indented,
|
||||
JsonConverters.Converters
|
||||
);
|
||||
string sub = data.Length < 5000 ? data : data.Substring(0, 5000) + "\n. . . ";
|
||||
_resultsText.text = sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f54a6bac8f0048a3a30e4d15baaaff9
|
||||
timeCreated: 1480376499
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user