public async void OnTapAndHold(LatLonAlt latLonAlt) { if (ReferenceEquals(MapSession.Current, null) || string.IsNullOrEmpty(MapSession.Current.DeveloperKey)) { Debug.LogError( "Provide a Bing Maps key to use the map services. " + "This key can be set on a MapSession component."); return; } var finderResult = await MapLocationFinder.FindLocationsAt(latLonAlt.LatLon); string formattedAddressString = null; if (finderResult.Locations.Count > 0) { formattedAddressString = finderResult.Locations[0].Address.FormattedAddress; } if (_mapPinPrefab != null) { // Create a new MapPin instance at the specified location. var newMapPin = Instantiate(_mapPinPrefab); newMapPin.Location = latLonAlt.LatLon; var textMesh = newMapPin.GetComponentInChildren <TextMeshPro>(); textMesh.text = formattedAddressString ?? "No address found."; _mapPinLayer.MapPins.Add(newMapPin); } }
public async void OnMapSent(LatLon latLon) { var location = latLon; var finderResult = await MapLocationFinder.FindLocationsAt(location); string formattedAddressString = null; if (finderResult.Locations.Count > 0) { formattedAddressString = finderResult.Locations[0].Address.FormattedAddress; } var textMesh = text; textMesh.text = formattedAddressString ?? "No address found."; Debug.Log(formattedAddressString ?? "No address found."); // _mapPinLayer.MapPins.Add(newMapPin); }
public async void OnMapClick(MixedRealityPointerEventData mixedRealityPointerEventData) { Debug.Log("Map clicked event " + mixedRealityPointerEventData); if (string.IsNullOrEmpty(MapServices.BingMapsKey)) { Debug.LogError( "Provide a Bing Maps key to use the map services. " + "This key can either be set on the MapRenderer or directly in code through MapServices.BingMapsKey property."); return; } var focusProvider = CoreServices.InputSystem.FocusProvider; if (focusProvider.TryGetFocusDetails(mixedRealityPointerEventData.Pointer, out var focusDetails)) { var location = _mapRenderer.TransformWorldPointToLatLon(focusDetails.Point); var finderResult = await MapLocationFinder.FindLocationsAt(location); string formattedAddressString = null; if (finderResult.Locations.Count > 0) { formattedAddressString = finderResult.Locations[0].Address.FormattedAddress; } if (_mapPinPrefab != null) { // Create a new MapPin instance, using the location of the focus details. var newMapPin = Instantiate(_mapPinPrefab); newMapPin.Location = location; var textMesh = newMapPin.GetComponentInChildren <TextMeshPro>(); textMesh.text = formattedAddressString ?? "No address found."; _mapPinLayer.MapPins.Add(newMapPin); Debug.Log("New pin added " + _mapPinLayer.MapPins.Count); } } else { // Unexpected. Debug.LogWarning("Unable to get FocusDetails from Pointer."); } }