none
Waypoint pushpin alphabet displayed incorrectly on the map RRS feed

  • Question

  • Hi,

    I am using Bing Maps on my Windows Store (8.1) application. In this app, I am displaying the route by assigning a WaypointCollection to the map's directionManager as follows:

    WaypointstartWaypoint = newWaypoint(locn1);WaypointendWaypoint = newWaypoint(locn2);WaypointCollectionwaypoints = newWaypointCollection();

    waypoints.Add(startWaypoint);

    waypoints.Add(endWaypoint);

    directionsManager.Waypoints = waypoints;

    RouteResponsecopyResponse = awaitdirectionsManager.CalculateDirectionsAsync();// Display the route on the map

    directionsManager.ShowRoutePath(currentRoute);      

    By this, the route is displayed correctly.

    Now if I add another Waypoint to the collection, the alphabets on the pushpins displayed on the Map do not correspond to the alphabets displayed on the RouteSummaryView.

    How can I control the naming of the waypoint so that the map pins and the location from RouteSummaryView are in sync?

    Thanks in advance!

    Wednesday, May 28, 2014 6:53 AM

Answers

  • I'm able to reproduce this issue. It looks like the letters on the map are being reversed for A and B. I'll pass this on to our development team to be fixed.

    http://rbrundritt.wordpress.com

    Wednesday, May 28, 2014 8:48 AM
  • The dev team has provided a couple of workarounds until this is corrected:

    Workaround 1:

    Manually find pushpin and update Text – note that this might not work if there is different type of pushpin (e.g. via pushpin) on the map – but I think that for simple route (showing only Waypoints), this will work.

    // Get directions

    var result = await map.DirectionsManager.CalculateDirectionsAsync();

    // manually find pushpin on map and set Text if there are more than 2 Waypoint

    if (map.DirectionsManager.ActiveRoute != null &&

        map.DirectionsManager.ActiveRoute.RouteLegs.Count > 2 &&

        map.DirectionsManager.ActiveRoute.RouteMode == RouteModeOption.Driving)

    {

    // Find MapLayer containing pushpin.

    MapLayer directionsLayer = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(map, 0), 0), 0) as MapLayer;

           int pushpinCount = VisualTreeHelper.GetChildrenCount(directionsLayer);

    if (pushpinCount > 2)

           {

    char currentChar = 'B';

           // skip last two pushpin, which are start and end pushpins.

    for (int i = 0; i < pushpinCount - 2; i++)

    {

    Pushpin currentPushpin = VisualTreeHelper.GetChild(directionsLayer, i) as Pushpin;

                         currentPushpin.Text = currentChar.ToString();

                         currentChar++;

                  }

                  // lastly fix the start pushpin

    Pushpin startPushpin = VisualTreeHelper.GetChild(directionsLayer, pushpinCount - 2) as Pushpin;

                  startPushpin.Text = "A";

            }

    }

    Workaround 2:  Override Pushpin template for Waypoint and use IValueConverter toset Text.  This is more complicated than above solution but much more flexible as this will allow the user to customize pushpin if they would like (e.g. change color, text style).

    For sample code, please refer to MainPage.xaml and MainPage.xaml.cs

    1.  Define Custom pushpin template in xaml and set the template to WaypointPushpinOptions (please refer to WaypointPinTemplate in MainPage.xaml)

    1. Define value converter which update the current pushpin text to the correct text (please refer to  PushpinTextConverter in MainPage.xaml.cs,)
    2. In the pushpin template, define TextBlock and bind its Text property to Parent’s Text property (please refer to WaypointText in MainPage.xaml) and set converter to the PushpinTextConverter in step 2.  Also set ConverterParameter to CollectionViewSource in static resource (collectionSource)

    4.  Set waypointPushpinOptions as defined in <Maps:Map.DirectionsRenderOptions> tag in MainPage.xaml

    1. Once you get directions in the code, assign the current RouteLegs to the collection source.

    // Get directions

    var result = await map.DirectionsManager.CalculateDirectionsAsync();

    collectionSource.Source = map.DirectionsManager.ActiveRoute.RouteLegs;


    http://rbrundritt.wordpress.com

    Friday, June 13, 2014 9:23 AM

All replies

  • I'm able to reproduce this issue. It looks like the letters on the map are being reversed for A and B. I'll pass this on to our development team to be fixed.

    http://rbrundritt.wordpress.com

    Wednesday, May 28, 2014 8:48 AM
  • The dev team has provided a couple of workarounds until this is corrected:

    Workaround 1:

    Manually find pushpin and update Text – note that this might not work if there is different type of pushpin (e.g. via pushpin) on the map – but I think that for simple route (showing only Waypoints), this will work.

    // Get directions

    var result = await map.DirectionsManager.CalculateDirectionsAsync();

    // manually find pushpin on map and set Text if there are more than 2 Waypoint

    if (map.DirectionsManager.ActiveRoute != null &&

        map.DirectionsManager.ActiveRoute.RouteLegs.Count > 2 &&

        map.DirectionsManager.ActiveRoute.RouteMode == RouteModeOption.Driving)

    {

    // Find MapLayer containing pushpin.

    MapLayer directionsLayer = VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(VisualTreeHelper.GetChild(map, 0), 0), 0) as MapLayer;

           int pushpinCount = VisualTreeHelper.GetChildrenCount(directionsLayer);

    if (pushpinCount > 2)

           {

    char currentChar = 'B';

           // skip last two pushpin, which are start and end pushpins.

    for (int i = 0; i < pushpinCount - 2; i++)

    {

    Pushpin currentPushpin = VisualTreeHelper.GetChild(directionsLayer, i) as Pushpin;

                         currentPushpin.Text = currentChar.ToString();

                         currentChar++;

                  }

                  // lastly fix the start pushpin

    Pushpin startPushpin = VisualTreeHelper.GetChild(directionsLayer, pushpinCount - 2) as Pushpin;

                  startPushpin.Text = "A";

            }

    }

    Workaround 2:  Override Pushpin template for Waypoint and use IValueConverter toset Text.  This is more complicated than above solution but much more flexible as this will allow the user to customize pushpin if they would like (e.g. change color, text style).

    For sample code, please refer to MainPage.xaml and MainPage.xaml.cs

    1.  Define Custom pushpin template in xaml and set the template to WaypointPushpinOptions (please refer to WaypointPinTemplate in MainPage.xaml)

    1. Define value converter which update the current pushpin text to the correct text (please refer to  PushpinTextConverter in MainPage.xaml.cs,)
    2. In the pushpin template, define TextBlock and bind its Text property to Parent’s Text property (please refer to WaypointText in MainPage.xaml) and set converter to the PushpinTextConverter in step 2.  Also set ConverterParameter to CollectionViewSource in static resource (collectionSource)

    4.  Set waypointPushpinOptions as defined in <Maps:Map.DirectionsRenderOptions> tag in MainPage.xaml

    1. Once you get directions in the code, assign the current RouteLegs to the collection source.

    // Get directions

    var result = await map.DirectionsManager.CalculateDirectionsAsync();

    collectionSource.Source = map.DirectionsManager.ActiveRoute.RouteLegs;


    http://rbrundritt.wordpress.com

    Friday, June 13, 2014 9:23 AM