Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
C#
private void hold_handler(object sender, System.Windows.Input.GestureEventArgs e)
    {
        Point x = e.GetPosition(this.googlemap);
        Point y = e.GetPosition(this.googlemap);
       // GeoCoordinate coordinate = e.GetPosition(googlemap);
        //string latlong = X.ToString() +" "+ Y.ToString();
        MessageBox.Show(x.ToString() + " "+y.ToString());
    }

And this is the XAML code:
XML
<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>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900