Answered by:
What actually does StringToLocationConverter ?

Question
-
Hi, I have tried the example given here, it doesn;t do anything. Just show (0,0) as coordinates. How can I get Map.Center ?Thursday, October 4, 2012 9:01 AM
Answers
-
The StringToLocationConverter is a IValueConverter that can convert a Location object into a string. This makes it easy for you to binding a Location property to TextBoxes or other text based objects. You can bind to the Center of the map, the bounding box coordinates, the coordinates of a pushpin or just about any object that has a Location property.
http://rbrundritt.wordpress.com
- Proposed as answer by Ricky_Brundritt Thursday, October 4, 2012 9:34 AM
- Marked as answer by Xyroid Thursday, October 4, 2012 10:28 AM
- Unmarked as answer by Xyroid Thursday, October 4, 2012 6:45 PM
- Marked as answer by Ricky_Brundritt Friday, October 5, 2012 2:26 PM
Thursday, October 4, 2012 9:34 AM -
Turning mode OneWay is not working. Still getting "0.000000, 0.000000"
- Marked as answer by Ricky_Brundritt Friday, October 5, 2012 2:26 PM
Friday, October 5, 2012 5:00 AM
All replies
-
The StringToLocationConverter is a IValueConverter that can convert a Location object into a string. This makes it easy for you to binding a Location property to TextBoxes or other text based objects. You can bind to the Center of the map, the bounding box coordinates, the coordinates of a pushpin or just about any object that has a Location property.
http://rbrundritt.wordpress.com
- Proposed as answer by Ricky_Brundritt Thursday, October 4, 2012 9:34 AM
- Marked as answer by Xyroid Thursday, October 4, 2012 10:28 AM
- Unmarked as answer by Xyroid Thursday, October 4, 2012 6:45 PM
- Marked as answer by Ricky_Brundritt Friday, October 5, 2012 2:26 PM
Thursday, October 4, 2012 9:34 AM -
Can you please give me small example code ?Thursday, October 4, 2012 10:28 AM
-
There was sample code in the link you provided, although it looks like the formatting is a bit messed up with the "strong" tags:
<Page x:Class="Application2.BlankPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:Application2" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:bm="using:Bing.Maps" mc:Ignorable="d"> <Page.Resources> <bm:StringToLocationConverter x:Key="LocationConverter"/> </Page.Resources> <Grid Background="{StaticResource ApplicationPageBackgroundBrush}"> <StackPanel Margin="20"> <TextBlock Text="{Binding ElementName=map, Path=Center, Mode=OneWay, Converter={StaticResource LocationConverter}}" Margin=”0 10 0 10” Width="250" Height="50"/> <bm:Map Width="800" Height="600" x:Name="map" Credentials="INSERT_YOUR_BING_MAPS_KEY"/> </StackPanel> </Grid> </Page>
http://rbrundritt.wordpress.com
- Edited by Ricky_Brundritt Thursday, October 4, 2012 10:34 AM
Thursday, October 4, 2012 10:32 AM -
I already checked that sample code and then added this code, I should get the lat long in textblock, but textblock doesn't get updated. I have Mode=TwoWay
void map_Tapped(object sender, TappedRoutedEventArgs e) { var pos = e.GetPosition(map); Location location; map.TryPixelToLocation(pos, out location); map.Center = location;
System.Diagnostics.Debug.WriteLine(myTextBlock.Text); // output is always "0.000000, 0.000000" }
- Edited by Xyroid Thursday, October 4, 2012 11:09 AM
Thursday, October 4, 2012 10:53 AM -
What happens when you turn mode to OneWay? This may be a requirement.
http://rbrundritt.wordpress.com
Thursday, October 4, 2012 5:06 PM -
The Converter is not overly useful since the position properties are not data bindable.Thursday, October 4, 2012 5:48 PM
-
Turning mode OneWay is not working. Still getting "0.000000, 0.000000"
- Marked as answer by Ricky_Brundritt Friday, October 5, 2012 2:26 PM
Friday, October 5, 2012 5:00 AM -
See Kristoffers post. It looks like this is something used internally at the moment that is being made available in case someone needs it but there doesn't seem to be a good example of it. I'll pass this on to the documentation team.
http://rbrundritt.wordpress.com
Friday, October 5, 2012 7:06 AM -
OK, thanks Richard :)Friday, October 5, 2012 8:46 AM