I am trying to use Google Maps control in windows phone 8. I have integrated it with Bing maps control as there is no other option to include Google Maps in windows phone 8 application. I want to enable the user to select a position on the map and get the latitude and longitude when the user long holds at the desired position. I have been using the following code but it gives me the wrong values. I have searched over and over again but unable to find a solution.
private void hold_handler(object sender, System.Windows.Input.GestureEventArgs e)
{
Point x = e.GetPosition(this.googlemap);
Point y = e.GetPosition(this.googlemap);
MessageBox.Show(x.ToString() + " "+y.ToString());
}
And this is the XAML code:
<Microsoft_Phone_Controls_Maps:Map Name="googlemap" Margin="0,161,0,0" CopyrightVisibility="Collapsed" LogoVisibility="Collapsed" ScaleVisibility="Visible" CredentialsProvider="ApBXPZf5IR94SLXE8nh5FYsb5WHKrH1XPY7428-EqQudseivcWhCROIJvGmtnkAV" DoubleTap="double_handler" Hold="hold_handler">
<Microsoft_Phone_Controls_Maps:Map.Mode>
<MSPCMCore:MercatorMode/>
</Microsoft_Phone_Controls_Maps:Map.Mode>
<Microsoft_Phone_Controls_Maps:MapTileLayer Name="street" Margin="0,0,0,32" DoubleTap="handler_doubleclick" Tap="tap_handler">
<Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Street"/>
</Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
</Microsoft_Phone_Controls_Maps:MapTileLayer>
<Microsoft_Phone_Controls_Maps:MapTileLayer Visibility="Collapsed" Name="wateroverlay" Margin="0,0,0,32">
<Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="WaterOverlay"/>
</Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
</Microsoft_Phone_Controls_Maps:MapTileLayer>
<Microsoft_Phone_Controls_Maps:MapTileLayer Visibility="Collapsed" Name="hybrid" Margin="0,0,0,32">
<Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Hybrid"/>
</Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
</Microsoft_Phone_Controls_Maps:MapTileLayer>
<Microsoft_Phone_Controls_Maps:MapTileLayer Visibility="Collapsed" Name="satellite" Margin="0,0,0,32">
<Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Satellite"/>
</Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
</Microsoft_Phone_Controls_Maps:MapTileLayer>
<Microsoft_Phone_Controls_Maps:MapTileLayer Visibility="Collapsed" Name="physical" Margin="0,0,0,32">
<Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
<GoogleTileSource:GoogleTile TileTypes="Physical"/>
</Microsoft_Phone_Controls_Maps:MapTileLayer.TileSources>
</Microsoft_Phone_Controls_Maps:MapTileLayer>
</Microsoft_Phone_Controls_Maps:Map>