This is a migrated thread and some comments may be shown as answers.

MapLine not working with inline syntax?

3 Answers 29 Views
Map
This is a migrated thread and some comments may be shown as answers.
Johannes
Top achievements
Rank 1
Johannes asked on 10 Apr 2013, 08:45 AM
I have trouble with some of my map elements, for example MapLine.

When I use this syntax the MapLine is displayed in red and shows a tooltip when mouse is over.

<tel:MapLine
  StrokeThickness="5"
  Stroke="Red"
  Point1="{Binding MyViewModel.Point1}"
  Point2="{Binding MyViewModel.Point2}"
  ToolTip="{Binding MyViewModel.ItemName}" />


When I use this syntax the MapLine is not displayed and there is no tooltip.

<tel:MapLine
  StrokeThickness="5"
  Point1="{Binding MyViewModel.Point1}"
  Point2="{Binding MyViewModel.Point2}">
  <tel:MapLine.Stroke>
    <SolidColorBrush Color="Red" />
  </tel:MapLine.Stroke>
  <tel:MapLine.ToolTip>
    <TextBlock Text="{Binding MyViewModel.ItemName}" />
  </tel:MapLine.ToolTip>
</tel:MapLine>

3 Answers, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 10 Apr 2013, 12:48 PM
Hi Johannes,

The map shape is quite specific object. For a case with this kind of tooltip the MapLine will be used as data context for the text block. So, you should specify the binding of text property like following:
<tel:MapLine
  StrokeThickness="5"
  Point1="{Binding MyViewModel.Point1}"
  Point2="{Binding MyViewModel.Point2}">
  <tel:MapLine.Stroke>
    <SolidColorBrush Color="Red" />
  </tel:MapLine.Stroke>
  <tel:MapLine.ToolTip>
    <TextBlock Text="{Binding DataContext.MyViewModel.ItemName}" />
  </tel:MapLine.ToolTip>
</tel:MapLine>

We can't reproduce the problem when the MapLine is not displayed using the syntax above. Could you, please, provide us with a small sample solution which reproduces it?

Regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Johannes
Top achievements
Rank 1
answered on 10 Apr 2013, 01:36 PM
Thanks for your quick response. I changed the ToolTip syntax as shown and it worked. I also solved the display/Stroke problem by using a ColorToSolidColorBrush Converter and using the first syntax. So now I can display MapLines on my RadMap.

Please allow me another question:
I use two InformationLayers to display MapElements. The 1st displays FrameworkElements designed by DataTemplate (Grid, Elements inside that Grid and a Popup filled with data). I can open/close this Popup when a user clicks on the FrameworkElement. The 2nd Layer displays the MapLines from above. I also want the behavior from my 1st Layer on the 2nd one, but it seems when using MapShapes instead of FrameworkElement there is only one Element allowed inside DataTemplate.

<tel:InformationLayer ItemsSource="{Binding MyMapItems}">
  <tel:InformationLayer.ItemTemplate>
    <DataTemplate>
      <tel:MapLine Point1="{Binding Point1}" Point2="{Binding Point2}" ... />
      <!-- I need more than just a single MapLine to display my MapItems, for example a Popup Element -->
       <!-- <Popup ... /> -->
    </DataTemplate>
  </tel:InformationLayer.ItemTemplate>
</tel:InformationLayer>

When I wrap the MapShape with a Grid to add additional Elements the MapShape is not displayed at all. I hope this is comprehensible.
0
Accepted
Andrey
Telerik team
answered on 11 Apr 2013, 10:53 AM
Hi Johannes,

Because of the specific of the map shape objects they can be used only as a root element in the data template. You can create control to show additional information over the map shape programmatically. For example:

private void ShapeMouseEnter(object sender, MouseEventArgs e)
{
    MapShape shape = sender as MapShape;
    if (shape != null)
    {
        Location location = Location.GetCoordinates(this.radMap, e.GetPosition(this.radMap));
 
        ContentControl content = shape.Tag as ContentControl;
        if (shape.Tag == null)
        {
            content = new ContentControl();
            content.Content = shape.ExtendedData;
            content.ContentTemplate = this.Resources["PopupTemplate"] as DataTemplate;
            shape.Tag = content;
        }
        MapLayer.SetLocation(content, location);
 
        if (content != null)
        {
            this.informationLayer.Items.Add(content);
        }
    }
}
 
private void ShapeMouseLeave(object sender, MouseEventArgs e)
{
    MapShape shape = sender as MapShape;
    if (shape != null)
    {
        ContentControl content = shape.Tag as ContentControl;
        if (content != null)
        {
            this.informationLayer.Items.Remove(content);
        }
    }
}


Regards,
Andrey Murzov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Map
Asked by
Johannes
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Johannes
Top achievements
Rank 1
Share this question
or