// Update is called once per frame void Update() { //allows realtime zoom and location changing on map //smallest allowed zoom if (zoom < 2) { zoom = 2; } //max allowed zoom if (zoom > 22) { zoom = 22; } map.GetComponent <AbstractMap>().UpdateMap(Conversions.StringToLatLon(location), zoom); if (enable3DTerrain) { ITerrainLayer terrain = map.GetComponent <AbstractMap>().Terrain; terrain.SetElevationType(ElevationLayerType.LowPolygonTerrain); } else { ITerrainLayer terrain = map.GetComponent <AbstractMap>().Terrain; terrain.SetElevationType(ElevationLayerType.FlatTerrain); } }
// Start is called before the first frame update void Awake() { map = new GameObject("Map"); //centre the map and mapHolder map.transform.position = new Vector3(0, 0, 0); MapHolder.transform.position = new Vector3(0, 0, 0); map.AddComponent <AbstractMap>(); MapOptions options = map.GetComponent <AbstractMap>().Options; options.locationOptions.latitudeLongitude = location; options.locationOptions.zoom = zoom; options.scalingOptions.unityTileSize = plotScale; IImageryLayer image = map.GetComponent <AbstractMap>().ImageLayer; image.SetLayerSource(ImagerySourceType.MapboxDark); IVectorDataLayer layer = map.GetComponent <AbstractMap>().VectorData; layer.SetLayerSource(VectorSourceType.MapboxStreets); layer.AddPolygonFeatureSubLayer("buildings", "building"); layer.FindFeatureSubLayerWithName("buildings").materialOptions.SetStyleType(StyleTypes.Light); if (enable3DTerrain) { ITerrainLayer terrain = map.GetComponent <AbstractMap>().Terrain; terrain.SetElevationType(ElevationLayerType.LowPolygonTerrain); } map.transform.parent = MapHolder.transform; map.GetComponent <AbstractMap>().SetPlacementType(MapPlacementType.AtTileCenter); InitalizeInteraction(); if (!String.IsNullOrEmpty(titleName) && Text != null) { GameObject title = Instantiate(Text, new Vector3(0, 2.5f, 0) * plotScale, Quaternion.identity); //place title so it is just above plot title.transform.position = title.transform.position + new Vector3(0, title.GetComponent <Renderer>().bounds.size.y / 2, 0) * plotScale; //add title title.transform.parent = MapHolder.transform; title.GetComponent <TextMesh>().text = titleName; title.transform.name = "title"; //scale the size of text depending on PlotScale title.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f) * plotScale; //place title so it is just above plot title.transform.position = title.transform.position + new Vector3(0, title.GetComponent <Renderer>().bounds.size.y / 2, 0); } map.AddComponent <HistoGramOnMap>(); map.GetComponent <HistoGramOnMap>().locationStrings = locationStrings; map.GetComponent <HistoGramOnMap>().heightValues = heightValues; map.GetComponent <HistoGramOnMap>().colours = colours; map.GetComponent <HistoGramOnMap>().spawnScale = spawnScale; map.GetComponent <HistoGramOnMap>().HeightScaleMax = HeightScaleMax; map.GetComponent <HistoGramOnMap>().HeightScaleMin = HeightScaleMin; map.GetComponent <HistoGramOnMap>().map = map.GetComponent <AbstractMap>(); }