none
How to increase touch size on Bing Map WPF?

    Question

  • Hi everyone, I have multiple polylines on the map and each one can be selected by using touch. But the problem here is it's really hard to touch to the polyline because the screen recognizes the touch as 1 point. So in order to select a polyline, I have to touch exactly on the polyline and it costs a lot of time. So is there any way to increase the area effect of the touch so that I can delete the polyline without wasting time? Thanks a lot. 
    Tuesday, October 29, 2013 7:27 PM

Answers

  • There are two options. the first option is to give the polylines a bigger thickness so they are easier to click. The second option is to take a click coordinates and do a search against all the coordinates of data on the map to see if the touch was within a shot pixel distance from a data coordinate. This will help if you try touching a polyline near one of it's points, but won't help if the coordinates are far apart and you try clicking in between.

    A possible third option might be to a tap event to the map and if a polyline isn't also tapped, then try taking the event args and slightly changing the touch points a few pixels and invoke a new tap event on the app. Not sure how best to go about this route.


    http://rbrundritt.wordpress.com

    Wednesday, October 30, 2013 8:42 AM
    Owner

All replies

  • There are two options. the first option is to give the polylines a bigger thickness so they are easier to click. The second option is to take a click coordinates and do a search against all the coordinates of data on the map to see if the touch was within a shot pixel distance from a data coordinate. This will help if you try touching a polyline near one of it's points, but won't help if the coordinates are far apart and you try clicking in between.

    A possible third option might be to a tap event to the map and if a polyline isn't also tapped, then try taking the event args and slightly changing the touch points a few pixels and invoke a new tap event on the app. Not sure how best to go about this route.


    http://rbrundritt.wordpress.com

    Wednesday, October 30, 2013 8:42 AM
    Owner
  • Hi Rick, I was trying to implement the second way but it doesn't work. Could you please help me to solve this? Thanks a lot. Here is my code:

    void newPolylinePP_TouchDown(object sender, TouchEventArgs e) { if (e.TouchDevice.GetTagData().Value == 7) { var touchPosition = e.GetTouchPoint(_map); var touchLocation = _map.ViewportPointToLocation(touchPosition.Position); List<Location> data = new List<Location>();

    int count = 0; foreach (MapPolyline polyline in FindVisualChildren<MapPolyline>(_map)) { count++; } for (int i = 0; i < count; i++) { foreach (MapPolyline polyline in FindVisualChildren<MapPolyline>(_map)) { for (int j = 0; j < polyline.Locations.Count; j++) { var loc = polyline.Locations.ElementAt(j); data.Add(new Location(loc.Latitude, loc.Longitude)); } } } Location minValue = data.ElementAt(0); int minIndex = 0; var minLatitude = Math.Abs(touchLocation.Latitude - data.ElementAt(0).Latitude); var minLongitude = Math.Abs(touchLocation.Longitude - data.ElementAt(0).Longitude); for (int i = 1; i < data.Count;i++ ) { if (minLatitude >= Math.Abs(touchLocation.Latitude - data.ElementAt(i).Latitude) && minLongitude >= Math.Abs(touchLocation.Longitude - data.ElementAt(i).Longitude)) { minValue = data.ElementAt(i); minIndex = i; } } for (int i = 0; i < count; i++) { foreach (MapPolyline polyline in FindVisualChildren<MapPolyline>(_map)) { if (polyline.Locations.Contains(data.ElementAt(minIndex))) { _map.Children.Remove(polyline); return; } } } } }



    • Edited by Faro Luce Thursday, October 31, 2013 6:39 PM
    Thursday, October 31, 2013 6:38 PM