public void HidePopup() { if (selectedPopup != null) { selectedPopup.SetActive(false); targetMarker = null; } }
public void HideAllPanels() { _selectedMarker = null; detailsPanelGameObject.SetActive(false); HideTimeVisualizationPanel(); HideTimeSlider(); HideFiltersPanel(); HideLoadingData(); HideHelpWindow(); }
/// <summary> /// This method is called by clicking on the map /// </summary> private void OnMapClick() { // Remove active marker reference targetMarker = null; // Hide the popup selectedPopup?.SetActive(false); // Remove active popup reference selectedPopup = null; }
public void addMarkerInstance(MapPointMarker mapPointMarker) { mapPointMarker.assignTexture(null); GameObject markerGameObject = GameObject.Instantiate(customMarkerGameObject, customMarkerCanvas.transform) as GameObject; //gObject.transform.parent = mapPointMarker.getMarker3D().instance.transform; RectTransform rectTransform = markerGameObject.transform as RectTransform; //rectTransform.SetParent(customMarkerContainer); markerGameObject.transform.localScale = Vector3.one; MarkerInstance marker = new MarkerInstance(); MarkerData data = new MarkerData(); data.title = mapPointMarker.getGridCluster().getNumPoints().ToString(); data.longitude = mapPointMarker.getX(); data.latitude = mapPointMarker.getY(); marker.data = data; marker.gameObject = markerGameObject; marker.transform = rectTransform; //marker.transform.Rotate(new Vector3(90, 180, 0)); /* * Quaternion quatRotation = Quaternion.identity; * quatRotation.x = 45; * quatRotation.y = 180; * * marker.transform.localRotation = quatRotation;*/ marker.mapMarker = mapPointMarker; mapPointMarker.markerInstance = marker; mapPointMarker.getMarker2D().texture = null; mapPointMarker.getMarker2D().enabled = false; if (mapPointMarker.getMarker3D() != null) { mapPointMarker.getMarker3D().enabled = false; mapPointMarker.getMarker3D().instance.SetActive(false); } SetText(rectTransform, "Title", data.title); markers.Add(marker); }
public void SetSelectedMarker(MapPointMarker marker) { _selectedMarker = marker; }
private void AppendObjectsToMap(ManMadeObject[] objectList) { var objCount = objectList.Length; var listOfPoints = new List <MapPoint>(); for (var index = 0; index < objCount; index++) { var obj = objectList[index]; if (obj.production?.location == null) { continue; } /* * if (numObject == 300) * Debug.Log("EL 300 es " + obj.id); * * if (numObject == 3000) * Debug.Log("EL 3000 es " + obj.id); * * if (numObject == 15000) * Debug.Log("EL 15000 es " + obj.id); * * numObject++; */ /* PRUEBA RENDIMIENTO */ var listOfCenturies = new List <TimeElement>(); if (obj.production?.time.Length > 0) { foreach (var timeElement in obj.production.time) { if (APIManager.instance.timeValues.TryGetValue(timeElement, out var time)) { listOfCenturies.Add(time); } } listOfCenturies = listOfCenturies.OrderBy(t => t.century).ToList(); } var objCategory = categoriesGroups[0]; var listOfCategories = new List <string>(); if (obj.production?.category != null && obj.production.category?.Length > 0 && obj.production.category[0] != null && obj.production.category[0].label != null) { listOfCategories = obj.production.category.Select(s => s.label).ToList(); switch (listOfCategories.Count) { case 0: objCategory = categoriesGroups[0]; break; case 1: { objCategory = categoriesDictionary.TryGetValue(listOfCategories[0], out var cat) ? cat : categoriesGroups[0]; break; } default: { var selectedCategories = new List <ScriptableCategory>(); foreach (var categoryName in listOfCategories) { if (!categoriesDictionary.TryGetValue(categoryName, out var cat)) { continue; } if (!selectedCategories.Contains(cat)) { selectedCategories.Add(cat); } } objCategory = selectedCategories.Count > 1 ? categoriesGroups[1] : selectedCategories[0]; selectedCategories.Clear(); break; } } } /* PRUEBA RENDIMIENTO */ foreach (var currentLocation in obj.production?.location) { var latitude = currentLocation.lat; var longitude = currentLocation.@long; if (float.IsNaN(latitude) || float.IsNaN(longitude)) { continue; } // Cada MapPoint tiene una serie de propiedades, la posición, escala y altitud vienen dentro de un objeto // MapPointMarker de OnlineMaps // Se añade la posicion (lat,long) y se asocia a un objeto 3d Cube, luego puede cambiarse var mapPoint = new MapPointMarker(longitude, latitude, prefabObject, false); //mapPoint.addPositionValue("Production", new Vector2(longitude, latitude)); if (mapPoint.getMarker3D() != null) { mapPoint.getMarker3D().altitude = 30.0f; mapPoint.getMarker3D().scale = 3.0f; } mapPoint.setMap(map); /* PRUEBA RENDIMIENTO */ // Se introducen el resto de propiedades (URI, categpry (clase), from y to (intervalo de tiempo) mapPoint.setURI(obj.id); mapPoint.setLabel(obj.label != null && obj.label.Length > 0 ? obj.label[0] : obj.identifier); if (obj.production?.time?.Length > 0) { map.GetPropertyManager().SetPropertyValue("time", mapPoint, obj.production.time.ToList()); if (listOfCenturies.Count > 0) { mapPoint.setFrom(listOfCenturies.First().@from); mapPoint.setTo(listOfCenturies.Last().to); } } //Set Properties values map.GetPropertyManager().SetPropertyValue("technique", mapPoint, obj.production.technique.ToList()); map.GetPropertyManager().SetPropertyValue("material", mapPoint, obj.production.material.ToList()); var listOfPlaces = obj.production.location.Select(s => s.label).ToList(); map.GetPropertyManager().SetPropertyValue("place", mapPoint, listOfPlaces); mapPoint.assignTexture(listOfPlaces.Count == 1 ? objCategory.defaultIcon: objCategory.multipleLocationIcon); mapPoint.setKnownLocation(listOfPlaces.Count == 1); map.GetPropertyManager().SetPropertyValue("category", mapPoint, listOfCategories); mapPoint.setDimension(map.GetDimension()); mapPoint.setMultipleLocations(obj.production.location.Length > 1); /* PRUEBA RENDIMIENTO */ listOfPoints.Add(mapPoint); } } map.addPoints(listOfPoints); }
protected MapPointMarker getClusterMarker(GridCluster gCluster, int id) { MapPointMarker mapPoint = new MapPointMarker(gCluster.getCenter().getX(), gCluster.getCenter().getY(), clusterPrefab, true); mapPoint.setGridCluster(gCluster); mapPoint.setLabel("Cluster " + id); //if(mapPoint.getMarker3D()!= null) // mapPoint.getMarker3D().instance.name = id.ToString(); mapPoint.setClusteredPoints(gCluster.getPoints()); mapPoint.setCluster(true); if (mapPoint.getMarker3D() != null) { mapPoint.getMarker3D().altitude = 30.0f; mapPoint.getMarker3D().altitudeType = OnlineMapsAltitudeType.absolute; mapPoint.getMarker3D().scale = getScale(gCluster, this.points.Count); } mapPoint.setMap(this); addMarkerInstance(mapPoint); if (mapPoint.isGroupPoint()) { var img = mapPoint.markerInstance.gameObject.GetComponentInChildren <Image>(); if (img != null) { img.sprite = customGroupPointMarker; foreach (var imgchild in img.GetComponentsInChildren <Image>()) { if (imgchild != img) { imgchild.sprite = customGroupPointMarker; } } } } gCluster.setCenter(mapPoint); //if (gCluster.isGroupPoints()) // Debug.Log("AQUI"); /* * * if (gCluster.getCategory().Equals("silknow.org/#pthing")) * { * SphereCollider sphereCollider = mapPoint.getMarker3D().instance.GetComponent<SphereCollider>(); * sphereCollider.radius = 1; * //mapPoint.getMarker3D().scale = mapPoint.getMarker3D().scale * 100.0f; * } * else * { * CapsuleCollider capsuleCollider = mapPoint.getMarker3D().instance.GetComponent<CapsuleCollider>(); * capsuleCollider.radius = 0.5f; * capsuleCollider.height = 1.5f; * capsuleCollider.direction = 1; * mapPoint.getMarker3D().altitude = 70.0f; * //mapPoint.getMarker3D().transform.position = mapPoint.getMarker3D().transform.position + new Vector3(0.0f, 60.0f, 0.0f); * //mapPoint.getMarker3D().al * * }*/ mapPoint.hide(); return(mapPoint); }
public void update() { int level; int c = 1; if (clusterManager.hasData()) { return; } distributeGroupsOnCircle(); updateClustering(); this.positionsGroup.Clear(); //Debug.Log("Hay " + clusterManager.getPointGroupClusters().Count + " gouppoints"); var crono3 = Stopwatch.StartNew(); foreach (GridCluster gCluster in clusterManager.getPointGroupClusters()) { MapPointMarker point = getClusterMarker(gCluster, -c); c++; } for (level = 0; level < clusterManager.getNumLevels(); level++) { this.clusterMarkers.Add(new List <MapPointMarker>()); this.clusterLines.Add(new List <OnlineMapsDrawingLine>()); // Each level , a list lines per cluster /* MEMO * List<List<OnlineMapsDrawingLine>> levelConnections = new List<List<OnlineMapsDrawingLine>>(); * for (int a = 0; a < clusterManager.getGridClustersAtLevel(level).Count; a++) * levelConnections.Add(new List<OnlineMapsDrawingLine>()); * * connectionsLinesPerLevel.Add(level, levelConnections); */ } for (level = 0; level < clusterManager.getNumLevels(); level++) { List <GridCluster> clusters = clusterManager.getGridClustersAtLevel(level); //Debug.Log("En el nivel " + level + " hay " + clusters.Count + " cluster "); if (clusters != null && clusters.Count > 0) // && !clusters[0].getCenter().isCluster()) { for (int i = 0; i < clusters.Count; i++) { // Creating cluster marker //MapPointMarker point = getClusterMarker(clusters[i], level * 1000 + i); MapPointMarker point = null; //Debug.Log("El cluster " + i + " del nivel " + level + " tiene " + clusters[i].getNumVisiblePoints() + " puntos visibles"); if (clusters[i].getNumVisiblePoints() == 1) { point = (MapPointMarker)(clusters[i].getPoints()[0]); } else { point = getClusterMarker(clusters[i], level * 1000 + i); } clusterMarkers[level].Add(point); if (level == 0) { clusters[i].initConnectionsList(clusters.Count); clusters[i].updateConnections(clusters); /* MEMO * List<List<OnlineMapsDrawingLine>> levelConnections = (List<List<OnlineMapsDrawingLine>>)connectionsLinesPerLevel[level]; * * for (int clusterCon = 0; clusterCon < clusters.Count; clusterCon++) * if (clusters[i].getConnections()[clusterCon] == 0) * levelConnections[i].Add(null); * else * levelConnections[i].Add(addConnection(clusters[i], clusters[clusterCon], clusters[i].getConnections()[clusterCon])); */ } } } } this.positionsGroup.Clear(); //Debug.Log($"markes y conections {crono2.ElapsedMilliseconds * 0.001f} segundos"); }
public new void reset() { this.resetted = false; if (markers != null) { foreach (MarkerInstance markerI in markers) { GameObject.DestroyImmediate(markerI.gameObject); } markers.Clear(); } for (int i = 0; i < points.Count; i++) { MapPointMarker point = (MapPointMarker)points[i]; if (point.isCluster() || !maintainPoints) { if (point.getMarker3D() != null) { point.getMarker3D().DestroyInstance(); } point.getMarker2D().DestroyInstance(); } } for (int i = 0; i < clusterMarkers.Count; i++) { List <MapPointMarker> clusterMarkersList = clusterMarkers[i]; for (int j = 0; j < clusterMarkersList.Count; j++) { //UnityEngine.Object.Destroy(clusterMarkersList[j].getMarker3D().prefab); clusterMarkersList[j].reset(); if (clusterMarkersList[j].getMarker3D() != null) { clusterMarkersList[j].getMarker3D().Dispose(); } if (clusterMarkersList[j].getMarker2D() != null) { clusterMarkersList[j].getMarker2D().Dispose(); } } clusterMarkersList.RemoveRange(0, clusterMarkersList.Count); } clusterMarkers.RemoveRange(0, clusterMarkers.Count); for (int i = 0; i < clusterLines.Count; i++) { List <OnlineMapsDrawingLine> clusterLinesList = clusterLines[i]; for (int j = 0; j < clusterLinesList.Count; j++) { clusterLinesList[j].Dispose(); } clusterLinesList.RemoveRange(0, clusterLinesList.Count); } base.reset(); clusterLines.RemoveRange(0, clusterLines.Count); List <int> keyList = new List <int>(); foreach (int el in connectionsLinesPerLevel.Keys) { keyList.Add(el); } for (int i = 0; i < keyList.Count; i++) { List <List <OnlineMapsDrawingLine> > levelConnections = (List <List <OnlineMapsDrawingLine> >)connectionsLinesPerLevel[keyList[i]]; for (int j = 0; j < levelConnections.Count; j++) { List <OnlineMapsDrawingLine> listLine = levelConnections[j]; for (int u = 0; u < listLine.Count; u++) { if (listLine[u] != null) { listLine[u].Dispose(); } } listLine.RemoveRange(0, listLine.Count); } connectionsLinesPerLevel.Remove(keyList[i]); } }
/// <summary> /// This method is called by clicking on the marker /// </summary> /// <param name="marker">The marker on which clicked</param> public void OnMarkerClick(MapPointMarker marker) { targetMarker = marker; //print("OnMarker click on "+targetMarker.getLabel()); // Set active marker reference if (targetMarker.isGroupPoint()) { // Show the popup itemTitlePopup.SetActive(false); selectedPopup = clusterPopup; var mcp = selectedPopup.GetComponent <MapClusterPopup>(); mcp.RemoveChildren(); //llamar a getfilteredclusteredpoints; foreach (var clusterPoint in targetMarker.getClusteredPointsNoFiltered()) { mcp.AddClusterItem(clusterPoint.getLabel(), clusterPoint.getURI()); //print("hola"); } selectedPopup.SetActive(true); } else if (!targetMarker.isCluster()) { // Show the popup clusterPopup.SetActive(false); selectedPopup = itemTitlePopup; selectedPopup.SetActive(true); // Set title and address title.text = marker.getLabel(); MapUIManager.instance.SetSelectedMarker(targetMarker); selectedPopup.GetComponent <RelationsLegendPopup>().ClearRows(); selectedPopup.GetComponent <RelationsLegendPopup>().PopulateLegend(); } else if (targetMarker.isCluster() && targetMarker.getGridCluster().getNumVisiblePoints() == 1) { var innerMarker = targetMarker.getGridCluster().getPoints()[0] as MapPointMarker; if (innerMarker == null) { return; } // Show the popup clusterPopup.SetActive(false); selectedPopup = itemTitlePopup; selectedPopup.SetActive(true); // Set title and address title.text = innerMarker.getLabel(); MapUIManager.instance.SetSelectedMarker(innerMarker); selectedPopup.GetComponent <RelationsLegendPopup>().ClearRows(); selectedPopup.GetComponent <RelationsLegendPopup>().PopulateLegend(); } else { targetMarker = null; } UpdatePopupPosition(); }
protected List <GridCluster> putPointMarkers(OnlineMapsTile tile, GameObject parent, Vector2 centerMap, int from, int to, float desp, Transform baseT) { int level = map.getViewedLevel(); //map.getLevel(); int numPoint = 0; List <GridCluster> groupPointList = new List <GridCluster>(); List <MapPoint> pointList = map.pointsInTime(from, to); //Debug.Log("Los puntos de " + from + " hasta " + to + " son :"); if (pointList == null) { return(null); } foreach (MapPoint p in pointList) { MapPointMarker gPoint = (MapPointMarker)p; float longitud = gPoint.getX(); float latitud = gPoint.getY(); if (tile.topLeft.x <= longitud && tile.bottomRight.x >= longitud && tile.topLeft.y >= latitud && tile.bottomRight.y <= latitud) { if (!p.isGroupPoint() && !p.isCluster() && p.isVisible()) { numPoint++; if (numPoint == 2 && from == 1701) { numPoint++; } //Debug.Log(p.getLabel() + "(" + gPoint.getMarker3D().transform.name + ") - " + p.getFrom() + "-" + p.getTo()); //-------------- GameObject marker = Instantiate(gPoint.getMarker3D().prefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); marker.transform.SetPositionAndRotation(marker.transform.position + new Vector3((-(float)(gPoint.getX())) + centerMap.x, desp, (-(float)(gPoint.getY())) + centerMap.y), marker.transform.rotation); foreach (Transform child in marker.transform) { //GameObject obj = child.gameObject; if (child.name.Equals("picture")) { child.GetComponent <Renderer>().material.mainTexture = gPoint.getTexture(); } } marker.transform.parent = parent.transform; //float scale = gPoint.getMarker3D().scale / 100.0f; //marker.transform.localScale = new Vector3(scale, scale, scale); float factor = baseT.localScale.x / 20.0f; marker.transform.localScale = new Vector3(factor, factor, factor); marker.AddComponent(typeof(EventTrigger)); EventTrigger trigger = marker.GetComponent <EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback.AddListener((eventData) => { onClick(); }); trigger.triggers.Add(entry); gPoint.setStackedGameObject(marker); stackedPoints.Add(gPoint); } else if (!groupPointList.Contains(p.getGroupPointCluster())) { //if(p.isInGroupPoint.getCenter().isVisible()) if (p.getGroupPointCluster() != null) { groupPointList.Add(p.getGroupPointCluster()); } } //-------------------- /* * gPoint.setStackedPosition(new Vector3((-(float)(gPoint.getX())) + centerMap.x, * -1.0f, * (-(float)(gPoint.getY())) + centerMap.y), parent.transform); * float scale = gPoint.getMarker3D().scale / 100.0f; * gPoint.setStackedScale(new Vector3(scale, scale, scale)); * * stackedPoints.Add(gPoint); */ } } return(groupPointList); }
protected void putClusterMarkers(OnlineMapsTile tile, GameObject parentCanvas, GameObject parent, Vector2 centerMap, int from, int to, float desp, Transform baseT) { int level = map.getViewedLevel(); //map.getLevel(); List <MapPointMarker> clusterList = ((MapMarker)(map)).getClusterMarkersAtLevel(level); for (int m = 0; m < clusterList.Count; m++) { List <MapPoint> pointList = clusterList[m].getClusteredPoints(); int numData = 0; if (pointList != null) { foreach (MapPoint pointC in pointList) { if (pointC.getFrom() >= from && pointC.getTo() <= to) { numData++; } } } else { if (clusterList[m].getFrom() >= from && clusterList[m].getTo() <= to) { numData++; } /* * if (clusters[i].getNumVisiblePoints() == 1) * point = (MapPointMarker)(clusters[i].getPoints()[0]); * else * point = getClusterMarker(clusters[i], level * 1000 + i); */ } if (numData > 0) { double longitud, latitud; MapPointMarker gPoint = clusterList[m]; //OnlineMapsMarker3D marker3D = gPoint.getMarker3DCloned(); //this.markers3DList.Add(marker3D); //gPoint.getMarker3D().GetPosition(out longitud, out latitud); //marker3D.GetPosition(out longitud, out latitud); longitud = gPoint.getX(); latitud = gPoint.getY(); GameObject clusterPrefab = ((MapMarker)(gPoint.getMap())).clusterPrefab; if (longitud >= tile.topLeft.x && longitud <= tile.bottomRight.x) { if (latitud <= tile.topLeft.y && latitud >= tile.bottomRight.y) { //------------------ //GameObject marker = Instantiate(clusterList[m].getMarker3D().prefab, // new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); GameObject marker = Instantiate(clusterPrefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); marker.transform.SetPositionAndRotation(marker.transform.position + new Vector3((-(float)(longitud)) + centerMap.x, desp, (-(float)(latitud)) + centerMap.y), marker.transform.rotation); marker.transform.parent = parent.transform; marker.name = gPoint.getLabel(); /* * GameObject markerCluster = Instantiate(clusterList[m].markerInstance.gameObject, * new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); * markerCluster.transform.SetPositionAndRotation(markerCluster.transform.position + * new Vector3((-(float)(longitud)) + centerMap.x, * -1.0f, * (-(float)(latitud)) + centerMap.y), markerCluster.transform.rotation); * markerCluster.transform.parent = parent.transform; */ Canvas canvasSlice = parentCanvas.GetComponent <Canvas>(); GameObject markerCluster = null; if (clusterList[m].markerInstance == null) { //markerCluster = Instantiate(gPoint.getMarker3D().prefab, // new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); markerCluster = Instantiate(clusterPrefab, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity); //marker.transform.SetPositionAndRotation(marker.transform.position + // new Vector3((-(float)(gPoint.getX())) + centerMap.x, // desp, // (-(float)(gPoint.getY())) + centerMap.y), marker.transform.rotation } else { markerCluster = GameObject.Instantiate(clusterList[m].markerInstance.gameObject, canvasSlice.transform) as GameObject; } markerCluster.transform.SetPositionAndRotation(marker.transform.localPosition, marker.transform.rotation); //markerCluster.transform.parent = parent.transform; RectTransform rectTransform = markerCluster.transform as RectTransform; //markerCluster.transform.localScale = new Vector3(0.1f,0.1f,0.1f); float factor = baseT.localScale.x / 1000.0f; markerCluster.transform.localScale = new Vector3(factor, factor, factor); markerCluster.transform.localRotation = Quaternion.Euler(new Vector3(-60, 180, 0)); markerCluster.transform.localPosition += Vector3.up * 0.6f; markerCluster.SetActive(!gPoint.isFiltered()); if (clusterList[m].markerInstance != null) { string titleData = numData.ToString(); SetText(rectTransform, "Title", titleData); } //float scale = (clusterList[m].getMarker3D().scale / 15.0f) * numData; //4.0f; //marker.transform.localScale = new Vector3(scale, scale, scale); gPoint.setStackedGameObject(marker); stackedPoints.Add(gPoint); if (gPoint.isFiltered() || !gPoint.isVisible()) { marker.SetActive(false); } else { marker.SetActive(true); } //------------------ /* * * gPoint.setStackedPosition(new Vector3((-(float)(gPoint.getX())) + centerMap.x, * -1.0f, * (-(float)(gPoint.getY())) + centerMap.y), parent.transform); * float scale = gPoint.getMarker3D().scale /6.0f; * gPoint.setStackedScale(new Vector3(scale, scale, scale)); * * stackedPoints.Add(gPoint); */ } } } } }
public void SetMarker(string id) { _marker = SilkMap.instance.map.getPointPerUri(id) as MapPointMarker; }
public void InitRelationShipIndicator(MapPointMarker mapPointMarker) { _mapPointMarker = mapPointMarker; var relations = _mapPointMarker.getRelations(); }