/// <summary> /// Initializes the map using the mapOptions. /// </summary> /// <param name="options">Options.</param> protected virtual void InitializeMap(MapOptions options) { Options = options; _worldHeightFixed = false; _fileSource = MapboxAccess.Instance; _centerLatitudeLongitude = Conversions.StringToLatLon(options.locationOptions.latitudeLongitude); _initialZoom = (int)options.locationOptions.zoom; options.scalingOptions.scalingStrategy.SetUpScaling(this); options.placementOptions.placementStrategy.SetUpPlacement(this); //Set up events for changes. _imagery.UpdateLayer += OnImageOrTerrainUpdateLayer; _terrain.UpdateLayer += OnImageOrTerrainUpdateLayer; _vectorData.SubLayerRemoved += OnVectorDataSubLayerRemoved; _vectorData.SubLayerAdded += OnVectorDataSubLayerAdded; _vectorData.UpdateLayer += OnVectorDataUpdateLayer; _options.locationOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { //take care of redraw map business... UpdateMap(); }; _options.extentOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { //take care of redraw map business... OnTileProviderChanged(); }; _options.extentOptions.defaultExtents.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { //take care of redraw map business... _tileProvider.UpdateTileExtent(); }; _options.placementOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { //take care of redraw map business... SetPlacementStrategy(); UpdateMap(); }; _options.scalingOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { //take care of redraw map business... SetScalingStrategy(); UpdateMap(); }; _mapVisualizer.Initialize(this, _fileSource); _tileProvider.Initialize(this); SendInitialized(); _tileProvider.UpdateTileExtent(); this.isReady = true; }
public void GenerateMyMap() { _fileSouce = MapboxAccess.Instance; _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } var latLonSplit = _latitudeLongitudeString.Split(','); _mapCenterLatitudeLongitude = new Vector2d(double.Parse(latLonSplit[0]), double.Parse(latLonSplit[1])); var referenceTileRect = Conversions.TileBounds(TileCover.CoordinateToTileId(_mapCenterLatitudeLongitude, _zoom)); _mapCenterMercator = referenceTileRect.Center; _worldRelativeScale = (float)(_unityTileSize / referenceTileRect.Size.x); Root.localScale = Vector3.one * _worldRelativeScale; _mapVisualizer.Initialize(this, _fileSouce); _tileProvider.Initialize(this); OnInitialized(); }
protected virtual void Awake() { _fileSouce = MapboxAccess.Instance; _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } }
void Awake() { _worldHeightFixed = false; _fileSouce = MapboxAccess.Instance; _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } }
private void Awake() { _access = MapboxAccess.Instance; _map = new DronesMap(); _terrainMaterial = new Material(Shader.Find("Custom/TerrainShader")); _imageFactory = new TerrainImageFactory(OnAllImageLoaded); _meshFactory = new BuildingMeshFactory(new SerialMeshBuilder(_map.BuildingProperties)); _filter = gameObject.AddComponent <MeshFilter>(); _renderer = gameObject.AddComponent <MeshRenderer>(); _renderer.sharedMaterial = _terrainMaterial; }
protected override void Awake() { base.Awake(); _fileSource = MapboxAccess.Instance; _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } }
protected virtual void Awake() { Debug.Log("AbstractMap::Awake"); _worldHeightFixed = false; _fileSouce = MapboxAccess.Instance; _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } }
void Awake() { if (!dev) { PersistantObject = GameObject.FindGameObjectWithTag("PersistantObject") as GameObject; script = PersistantObject.GetComponent <MapManager>(); coord = new Vector2d(script.lat, script.lon); } _worldHeightFixed = false; _fileSouce = MapboxAccess.Instance; _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } }
/// <summary> /// Initializes the map using the mapOptions. /// </summary> /// <param name="options">Options.</param> protected virtual void InitializeMap(MapOptions options) { Options = options; _worldHeightFixed = false; _fileSource = MapboxAccess.Instance; _centerLatitudeLongitude = Conversions.StringToLatLon(options.locationOptions.latitudeLongitude); _initialZoom = (int)options.locationOptions.zoom; options.scalingOptions.scalingStrategy.SetUpScaling(this); options.placementOptions.placementStrategy.SetUpPlacement(this); _mapVisualizer.Initialize(this, _fileSource); _tileProvider.Initialize(this); SendInitialized(); }
Button zoomIn, zoomOut; // buttons for adjusting zoom level protected virtual void Awake() { // set up search location input system if (_searchLocation != null) { _searchLocation.OnGeocoderResponse += SearchLocation_OnGeocoderResponse; } // set up tile generation _fileSouce = MapboxAccess.Instance; // what's this? _tileProvider.OnTileAdded += TileProvider_OnTileAdded; _tileProvider.OnTileRemoved += TileProvider_OnTileRemoved; if (!_root) { _root = transform; } }
static void OpenWindow() { EditorApplication.delayCall -= OpenWindow; //setup mapboxaccess listener _mapboxAccess = MapboxAccess.Instance; if (!_listeningForTokenValidation) { _mapboxAccess.OnTokenValidation += HandleValidationResponse; _listeningForTokenValidation = true; } //setup local variables from mapbox config file _mapboxConfig = _mapboxAccess.Configuration; if (_mapboxConfig != null) { _accessToken = _mapboxConfig.AccessToken; _memoryCacheSize = (int)_mapboxConfig.MemoryCacheSize; _fileCacheSize = (int)_mapboxConfig.FileCacheSize; _autoRefreshCache = _mapboxConfig.AutoRefreshCache; _webRequestTimeout = (int)_mapboxConfig.DefaultTimeout; } //validate current config if (!string.IsNullOrEmpty(_accessToken)) { SubmitConfiguration(); } //cache sample scene gui content GetSceneList(); _selectedSample = -1; //instantiate the config window instance = GetWindow(typeof(MapboxConfigurationWindow)) as MapboxConfigurationWindow; instance.minSize = new Vector2(800, 350); instance.titleContent = new GUIContent("Mapbox Setup"); instance.Show(); }
// --- public static IPromise <LatLong> GetLatLongForAddress(string streetAddress, string city, string country) { // Get access singleton (object that holds a token and associated geocoder). MapboxAccess access = MapboxAccess.Instance; Geocoder geocoder = access.Geocoder; var promise = new Promise <LatLong>(); string forwardGeocodeQuery = $"{streetAddress} {city} {country}"; Debug.Log($"Performing forward geocode with query \"{forwardGeocodeQuery}\""); ForwardGeocodeResource forwardGeocode = new ForwardGeocodeResource(forwardGeocodeQuery); geocoder.Geocode(forwardGeocode, (ForwardGeocodeResponse response) => { /* * Debug.Log($"Forward geocode response has features:"); * foreach (Feature feature in response.Features) { * Debug.Log($" - {feature.Id} {feature.PlaceName} {feature.Address} {feature.Center}"); * } */ // There are lots of interesting types of features returned by the API, places, POIs, localities, etc. // I'm assuming they're ordered by relevance, so let's just pick the first one. if (response.Features.Count > 0) { Feature chosenFeature = response.Features[0]; Vector2d coordinates = chosenFeature.Center; promise.Resolve(new LatLong((float)coordinates.x, (float)coordinates.y)); } else { promise.Resolve(new LatLong()); } }); return(promise); }
public void OnEnable() { _fileSource = MapboxAccess.Instance; }
protected IEnumerator SetupAccess() { _fileSource = MapboxAccess.Instance; yield return(new WaitUntil(() => MapboxAccess.Configured)); }
/// <summary> /// Initializes the map using the mapOptions. /// </summary> /// <param name="options">Options.</param> protected virtual void InitializeMap(MapOptions options) { Options = options; _worldHeightFixed = false; _fileSource = MapboxAccess.Instance; _centerLatitudeLongitude = Conversions.StringToLatLon(options.locationOptions.latitudeLongitude); _initialZoom = (int)options.locationOptions.zoom; options.scalingOptions.scalingStrategy.SetUpScaling(this); options.placementOptions.placementStrategy.SetUpPlacement(this); //Set up events for changes. _imagery.UpdateLayer += OnImageOrTerrainUpdateLayer; _terrain.UpdateLayer += OnImageOrTerrainUpdateLayer; _vectorData.SubLayerRemoved += OnVectorDataSubLayerRemoved; _vectorData.SubLayerAdded += OnVectorDataSubLayerAdded; _vectorData.UpdateLayer += OnVectorDataUpdateLayer; _options.locationOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { UpdateMap(); }; _options.extentOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { OnTileProviderChanged(); }; _options.extentOptions.defaultExtents.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { if (Application.isEditor && !Application.isPlaying && IsEditorPreviewEnabled == false) { Debug.Log("defaultExtents"); return; } if (TileProvider != null) { TileProvider.UpdateTileExtent(); } }; _options.placementOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { SetPlacementStrategy(); UpdateMap(); }; _options.scalingOptions.PropertyHasChanged += (object sender, System.EventArgs eventArgs) => { SetScalingStrategy(); UpdateMap(); }; _mapVisualizer.Initialize(this, _fileSource); TileProvider.Initialize(this); SendInitialized(); TileProvider.UpdateTileExtent(); }
/// <summary> /// Initializes the map using the mapOptions. /// </summary> /// <param name="options">Options.</param> protected virtual void InitializeMap(MapOptions options) { Options = options; _worldHeightFixed = false; _fileSource = MapboxAccess.Instance; _centerLatitudeLongitude = Conversions.StringToLatLon(options.locationOptions.latitudeLongitude); _initialZoom = (int)options.locationOptions.zoom; options.scalingOptions.scalingStrategy.SetUpScaling(this); options.placementOptions.placementStrategy.SetUpPlacement(this); _imagery.UpdateLayer += (object sender, System.EventArgs eventArgs) => { LayerUpdateArgs layerUpdateArgs = eventArgs as LayerUpdateArgs; if (layerUpdateArgs != null) { Debug.Log("<color=red>Image</color>"); _mapVisualizer.ReregisterTilesTo(layerUpdateArgs.factory); if (layerUpdateArgs.effectsVectorLayer) { _mapVisualizer.UnregisterTilesFrom(VectorData.Factory); VectorData.UpdateFactorySettings(); _mapVisualizer.ReregisterTilesTo(VectorData.Factory); } OnMapRedrawn(); } }; _terrain.UpdateLayer += (object sender, System.EventArgs eventArgs) => { LayerUpdateArgs layerUpdateArgs = eventArgs as LayerUpdateArgs; if (layerUpdateArgs != null) { Debug.Log("<color=green>Terrain</color>"); _mapVisualizer.ReregisterTilesTo(layerUpdateArgs.factory); if (layerUpdateArgs.effectsVectorLayer) { _mapVisualizer.UnregisterTilesFrom(VectorData.Factory); VectorData.UpdateFactorySettings(); _mapVisualizer.ReregisterTilesTo(VectorData.Factory); } OnMapRedrawn(); } }; _vectorData.UpdateLayer += (object sender, System.EventArgs eventArgs) => { LayerUpdateArgs layerUpdateArgs = eventArgs as LayerUpdateArgs; if (layerUpdateArgs != null) { Debug.Log("_vectorData.UpdateLayer"); _mapVisualizer.UnregisterTilesFrom(layerUpdateArgs.factory); VectorData.UpdateFactorySettings(); _mapVisualizer.ReregisterTilesTo(VectorData.Factory); OnMapRedrawn(); } }; _mapVisualizer.Initialize(this, _fileSource); _tileProvider.Initialize(this); SendInitialized(); _tileProvider.UpdateTileExtent(); }