public void InvokeHover(Point screenPosition, float scale, ISymbolCache symbolCache) { if (Hover == null) { return; } if (HoverLayers.Count == 0) { return; } var mapInfo = InfoHelper.GetMapInfo(Viewport, screenPosition, scale, HoverLayers, symbolCache); if (mapInfo?.Feature != _previousHoverEventArgs?.MapInfo.Feature) // only notify when the feature changes { var mapInfoEventArgs = new MapInfoEventArgs { MapInfo = mapInfo, NumTaps = 0, Handled = false }; _previousHoverEventArgs = mapInfoEventArgs; Hover?.Invoke(this, mapInfoEventArgs); } }
private void MapOnInfo(object sender, MapInfoEventArgs e) { var message = ToString(e.MapInfo.Feature); Debug.WriteLine(message); detail.Text = message; }
private void MapOnInfo(object?sender, MapInfoEventArgs args) { if (args.MapInfo?.Feature != null) { FeatureInfo.Text = $"Click Info:{Environment.NewLine}{args.MapInfo.Feature.ToDisplayText()}"; } }
private void MapOnInfo(object sender, MapInfoEventArgs e) { if (e.MapInfo.Feature == null) { return; } Debug.WriteLine(ToString(e.MapInfo.Feature)); }
private void MapControlOnInfo(object sender, MapInfoEventArgs e) { _writableLayer.Add(new Feature { Geometry = new Point(e.MapInfo.WorldPosition.X, e.MapInfo.WorldPosition.Y) }); _writableLayer.DataHasChanged(); }
private static void MapOnInfo(object sender, MapInfoEventArgs e) { var calloutStyle = e.MapInfo?.Feature?.Styles.Where(s => s is CalloutStyle).Cast <CalloutStyle>().FirstOrDefault(); if (calloutStyle != null) { calloutStyle.Enabled = !calloutStyle.Enabled; e.MapInfo?.Layer?.DataHasChanged(); // To trigger a refresh of graphics. } }
public void StopInfo(object sender, MapInfoEventArgs e) { if (e.MapInfo.Feature != null) { RunOnUiThread(new Runnable(Toast.MakeText( ApplicationContext, e.MapInfo.Feature?["Label"]?.ToString(), ToastLength.Short).Show)); } }
private void ShowPopup(MapInfoEventArgs args) { var mapControl = FindViewById <MapControl>(Resource.Id.mapcontrol); var screenPosition = mapControl.WorldToScreen(args.MapInfo.Feature.Geometry.GetBoundingBox().GetCentroid()); _popup.SetX((float)(screenPosition.X - _popup.MeasuredWidth * 0.5)); _popup.SetY((float)screenPosition.Y + 48); _popup.Visibility = ViewStates.Visible; }
/// <summary> /// press on point to view stop /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public async void StopInfo(object sender, MapInfoEventArgs e) { if (e.MapInfo.Feature != null) { //Console.WriteLine(e.MapInfo.Feature?["Name"]?.ToString() + e.MapInfo.Feature?["StreetName"]?.ToString()); Device.BeginInvokeOnMainThread(async() => { await DisplayAlert(e.MapInfo.Feature?["Name"]?.ToString(), e.MapInfo.Feature?["StreetName"]?.ToString() + ". " + e.MapInfo.Feature?["desc"]?.ToString(), "OK"); }); } }
private void HandlerInfo(object sender, MapInfoEventArgs e) { // Click on pin? Pin clickedPin = null; foreach (var pin in _pins) { if (pin.IsVisible && pin.Feature.Equals(e.MapInfo.Feature)) { clickedPin = pin; break; } } if (clickedPin != null) { SelectedPin = clickedPin; SelectedPinChanged?.Invoke(this, new SelectedPinChangedEventArgs(SelectedPin)); var pinArgs = new PinClickedEventArgs(clickedPin, _mapControl.Viewport.ScreenToWorld(e.MapInfo.ScreenPosition).ToForms(), e.NumTaps); PinClicked?.Invoke(this, pinArgs); if (pinArgs.Handled) { e.Handled = true; return; } } // Check for clicked drawables var drawables = GetDrawablesAt(_mapControl.Viewport.ScreenToWorld(e.MapInfo.ScreenPosition), _mapDrawableLayer); var drawableArgs = new DrawableClickedEventArgs( _mapControl.Viewport.ScreenToWorld(e.MapInfo.ScreenPosition).ToForms(), new Point(e.MapInfo.ScreenPosition.X, e.MapInfo.ScreenPosition.Y), e.NumTaps); // Now check each drawable until one handles the event foreach (var drawable in drawables) { drawable.HandleClicked(drawableArgs); if (!drawableArgs.Handled) { continue; } e.Handled = true; return; } // Call Info event, if there is one Info?.Invoke(sender, e); }
private void MapOnInfo(object sender, MapInfoEventArgs args) { if (args.MapInfo.Feature != null) { RunOnUiThread(new Runnable(Toast.MakeText( ApplicationContext, ToDisplayText(args.MapInfo.Feature), ToastLength.Short).Show)); ShowPopup(args); } }
private void MapControlOnInfo(object?sender, MapInfoEventArgs args) { if (args.MapInfo?.Feature != null) { FeatureInfoBorder.Visibility = Visibility.Visible; FeatureInfo.Text = $"Click Info:{Environment.NewLine}{args.MapInfo.Feature.ToDisplayText()}"; } else { FeatureInfoBorder.Visibility = Visibility.Collapsed; } }
private void AddPoint(MapInfoEventArgs args) { // For the sample we add this WritableLayer. Usually you would have your own handle to the WritableLayer if (!_mapControl.Map.Layers.Contains(_writableLayer)) { _mapControl.Map.Layers.Add(_writableLayer); } _writableLayer.Add(new Feature { Geometry = args.MapInfo.WorldPosition }); }
private void MapOnInfo(object sender, MapInfoEventArgs args) { if (args.MapInfo.Feature != null) { ShowPopup(args); } else { // Enable if you want to add points: // AddPoint(args); } }
private void ShowPopup(MapInfoEventArgs args) { var mapControl = FindViewById <MapControl>(Resource.Id.mapcontrol); var screenPosition = mapControl.Map.Viewport.WorldToScreen(args.MapInfo.Feature.Geometry.BoundingBox.Centroid); var screenPositionInPixels = mapControl.ToPixels(args.MapInfo.ScreenPosition); // todo use screenPosition to test WorldToScreen _popup.SetX((float)screenPositionInPixels.X); _popup.SetY((float)screenPositionInPixels.Y); _popup.Visibility = ViewStates.Visible; }
private void DragFeatureTo(MotionEvent motionEvent) { var mapInfoEventArgs = new MapInfoEventArgs { MapInfo = MapInfoHelper.GetMapInfo(Map.Layers.Where(l => l.IsMapInfoLayer), Viewport, GetScreenPosition(motionEvent, this), Renderer.SymbolCache), Type = MapInfoEventType.DragMove, Handled = false }; mapInfoEventArgs.MapInfo.Feature = _draggedFeature; OnInfo(mapInfoEventArgs); }
private void MapControlOnInfo(object sender, MapInfoEventArgs e) { if (e.MapInfo?.WorldPosition == null) { return; } _writableLayer?.Add(new GeometryFeature { Geometry = new Point(e.MapInfo.WorldPosition.X, e.MapInfo.WorldPosition.Y) }); _writableLayer?.DataHasChanged(); }
private void ShowPopup(MapInfoEventArgs args) { // Position on click position: // var screenPositionInPixels = args.MapInfo.ScreenPosition; // Or position on feature position: var screenPosition = _mapControl.Map.Viewport.WorldToScreen(args.MapInfo.Feature.Geometry.BoundingBox.Centroid); var screenPositionInPixels = _mapControl.ToPixels(screenPosition); _popup.SetX((float)screenPositionInPixels.X); _popup.SetY((float)screenPositionInPixels.Y); _popup.Visibility = ViewStates.Visible; }
private void MapOnInfo(object sender, MapInfoEventArgs args) { if (args.MapInfo?.Feature != null) { ShowPopup(args); } else { if (_popup != null && _popup.Visibility != ViewStates.Gone) { _popup.Visibility = ViewStates.Gone; } } }
private MapInfoEventArgs CheckStartDragHandled(MotionEvent motionEvent) { var mapInfoEventArgs = new MapInfoEventArgs { MapInfo = MapInfoHelper.GetMapInfo(Map.Layers.Where(l => l.IsMapInfoLayer), Viewport, GetScreenPosition(motionEvent, this), Renderer.SymbolCache), Type = MapInfoEventType.DragStart, Handled = false }; if (mapInfoEventArgs.MapInfo.Feature != null) { OnInfo(mapInfoEventArgs); } return(mapInfoEventArgs); }
/// <summary> /// On touching a MapInfo object, parse out the object Id and go to that object /// </summary> /// <param name="sender"></param> /// <param name="args"></param> public void MapOnInfo(object sender, MapInfoEventArgs args) { if (DateTime.Now > LastObjectSelection.AddSeconds(1)) //ensure that only 1 selection is made at one time { LastObjectSelection = DateTime.Now; var featureName = args.MapInfo.Feature?["Name"]?.ToString(); int geomId; Int32.TryParse((string)featureName, out geomId); if (geomId > 0) { var objId = geomId.ToString(); App.CurrentRoute = "//Records?objectId=" + objId; Shell.Current.GoToAsync($"//Records?objectId={objId}", true); } } }
private void MapOnInfo(object sender, MapInfoEventArgs args) { if (args.MapInfo.Feature != null) { ShowPopup(args); } else { if (_popup != null && _popup.Visibility != ViewStates.Gone) { _popup.Visibility = ViewStates.Gone; } // Enable if you want to add points: // AddPoint(args); } }
/// <summary> /// Check, if a widget or feature at a given screen position is clicked/tapped /// </summary> /// <param name="screenPosition">Screen position to check for widgets and features</param> /// <param name="startScreenPosition">Screen position of Viewport/MapControl</param> /// <param name="scale">Scale of scrren. Normally is 1, but could be greater.</param> /// <param name="symbolCache">Cache for symbols to determin size</param> /// <param name="widgetCallback">Callback, which is called when Widget is hiten</param> /// <param name="numTaps">Number of clickes/taps</param> /// <returns>True, if something done </returns> public bool InvokeInfo(Point screenPosition, Point startScreenPosition, float scale, ISymbolCache symbolCache, Action <IWidget, Point> widgetCallback, int numTaps) { var layerWidgets = Layers.Select(l => l.Attribution).Where(a => a != null); var allWidgets = layerWidgets.Concat(Widgets).ToList(); // Concat layer widgets and map widgets. // First check if a Widget is clicked. In the current design they are always on top of the map. var widget = WidgetTouch.GetWidget(screenPosition, startScreenPosition, scale, allWidgets); if (widget != null) { // TODO how should widgetCallback have a handled type thing? // Widgets should be iterated through rather than getting a single widget, // based on Z index and then called until handled = true; Ordered By highest Z widgetCallback(widget, new Point(screenPosition.X / scale, screenPosition.Y / scale)); return(true); } if (Info == null) { return(false); } var mapInfo = InfoHelper.GetMapInfo(Viewport, screenPosition, scale, InfoLayers, symbolCache); if (mapInfo != null) { // TODO Info items should be iterated through rather than getting a single item, // based on Z index and then called until handled = true; Ordered By highest Z var mapInfoEventArgs = new MapInfoEventArgs { MapInfo = mapInfo, NumTaps = numTaps, Handled = false }; Info?.Invoke(this, mapInfoEventArgs); return(mapInfoEventArgs.Handled); } return(false); }
private void OnMapInfo(object sender, MapInfoEventArgs e) { Messenger.Default.Send(new MapClickedMessage()); mapClickResetEvent.WaitOne(); mapClickResetEvent.Reset(); MapClickedResponseMessage message = messages.Dequeue(); if (message.Handled) { return; } if (e.MapInfo.Feature != null && e.MapInfo.Feature.Styles.First().Enabled) { StopLocation location = e.MapInfo.Feature["stopObject"] as StopLocation; Messenger.Default.Send(new StopSelectedMessage(location.Code, false)); return; } ShowNearbyStops(e.MapInfo.WorldPosition); map.ViewChanged(true); }
private void ShowPopup(MapInfoEventArgs args) { if (args.MapInfo?.Feature is IFeature geometryFeature) { // Position on click position: // var screenPositionInPixels = args.MapInfo.ScreenPosition; if (_mapControl == null) { return; } if (_popup == null) { return; } if (geometryFeature.Extent == null) { return; } // Or position on feature position: var screenPosition = _mapControl.Viewport.WorldToScreen(geometryFeature.Extent.Centroid); var screenPositionInPixels = _mapControl.ToPixels(screenPosition); _popup.SetX((float)screenPositionInPixels.X); _popup.SetY((float)screenPositionInPixels.Y); _popup.Visibility = ViewStates.Visible; if (_textView != null) { _textView.Text = geometryFeature.ToDisplayText(); } } }
private void MapOnInfo(object sender, MapInfoEventArgs e) { Debug.WriteLine(ToString(e.MapInfo.Feature)); }
private void MapControlOnHover(object sender, MapInfoEventArgs args) { FeatureInfo.Text = args.MapInfo.Feature == null ? "" : $"Hover Info:{Environment.NewLine}{args.MapInfo.Feature.ToDisplayText()}"; }
public async Task MapInfoAsync(object sender, MapInfoEventArgs e) { Logger.Log($" MapInfoAsync : Layer : {e.MapInfo.Layer.Name}"); }