/// <summary> /// Callback: a Geeo point of interest just entered the current user view. /// </summary> /// <param name="pointOfInterest">The actual point of interest.</param> private void Geeo_OnPointOfInterestEntered(PointOfInterest pointOfInterest) { // If the point of interest doesn't exist in the points of interest list and is not the current user, add it then display it if ((pointOfInterest.id != lastUserLocation.id) && !pointsOfInterestLocations.ContainsKey(pointOfInterest.id)) { PointOfInterestLocation pointOfInterestLocation = new PointOfInterestLocation(pointOfInterest.id, pointOfInterest.latitude, pointOfInterest.longitude, pointOfInterestLocationDisplayPointPrefab, displayMap.transform); pointsOfInterestLocations.Add(pointOfInterest.id, pointOfInterestLocation); DisplayPointOfInterestLocation(pointOfInterestLocation, true); } }
/// <summary> /// Callback: a Geeo point of interest just left the current user view. /// </summary> /// <param name="pointOfInterest">The actual point of interest.</param> private void Geeo_OnPointOfInterestLeft(PointOfInterest pointOfInterest) { // If the point of interest exists in the points of interest list, remove it from the list and hide/destroy it if (pointsOfInterestLocations.ContainsKey(pointOfInterest.id)) { PointOfInterestLocation pointOfInterestLocation = pointsOfInterestLocations[pointOfInterest.id]; pointsOfInterestLocations.Remove(pointOfInterest.id); DisplayPointOfInterestLocation(pointOfInterestLocation, false); Destroy(pointOfInterestLocation.displayPoint); } }
/// <summary> /// Display a point of interest's location point. /// </summary> /// <param name="pointOfInterestLocation">The point of interest's location to display or hide.</param> /// <param name="display">If the point of interest location should be displayed or hidden.</param> private void DisplayPointOfInterestLocation(PointOfInterestLocation pointOfInterestLocation, bool display = true) { // If the point of interest location should be displayed, update its position and display it if (display) { // Calculate the new point of interest location point's position by converting GPS coordinates to X/Y ones float pointOfInterestLocationX, pointOfInterestLocationY; LatitudeLongitudeToXY(pointOfInterestLocation.latitude, pointOfInterestLocation.longitude, out pointOfInterestLocationX, out pointOfInterestLocationY); pointOfInterestLocation.displayPoint.transform.position = new Vector3(pointOfInterestLocationX, pointOfInterestLocationY, pointOfInterestLocation.displayPoint.transform.localPosition.z); // Show the point of interest location point if (!pointOfInterestLocation.displayPoint.activeSelf) { pointOfInterestLocation.displayPoint.SetActive(true); } } // If the point of interest location should be hidden, hide it else if (pointOfInterestLocation.displayPoint.activeSelf) { pointOfInterestLocation.displayPoint.SetActive(false); } }