Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
i downloaded WPF Map App
then i added MapImage_MouseLeftButtonUp event for click and Mark a Point
this formula is sequel very good in Zoom '15'
but Not good in Others Zoom
my code is :
VB
Private Sub MapImage_MouseLeftButtonUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles MapImage.MouseLeftButtonUp
       If (location IsNot Nothing) Then
           '===========================================
           'Left Or Right
           Dim LRMove As Double = ((((e.GetPosition(MapImage).X) / (MapImage.ActualWidth / 100)) - 50) / 10000) * (2.15 * ((15 - zoom) + 1))
           'MsgBox(LRMove)
           Dim diffLeft As Double
           Dim shiftLeft As Double
           If (lng < 178) Then
               If (zoom = 15) Then
                   lng += LRMove
               ElseIf (zoom > 15) Then
                   diffLeft = zoom - 15
                   shiftLeft = ((15 - diffLeft) * LRMove) / 15
                   lng += shiftLeft
               Else
                   diffLeft = 15 - zoom
                   shiftLeft = ((15 + diffLeft) * LRMove) / 15
                   lng += shiftLeft
               End If
           Else
               lng = -180
           End If
           '===============================================
           'Top or Down
           Dim TDMove As Double = ((((e.GetPosition(MapImage).Y) / (MapImage.ActualHeight / 100)) - 50) / 10000) * (1.5 * ((15 - zoom) + 1))
           Dim diffTop As Double
           Dim shiftTop As Double
           If (lat > -88) Then
               If (zoom = 15) Then
                   lat -= TDMove
               ElseIf (zoom > 15) Then
                   diffTop = zoom - 15
                   shiftTop = ((15 + diffTop) * TDMove) / 15
                   lat += shiftTop
               Else
                   diffTop = 15 - zoom
                   shiftTop = ((15 - diffTop) * TDMove) / 15
                   lat -= shiftTop
               End If
           Else
               lat = -90
           End If
           '===============================================
           'ShowMapUsingLatLng()
           ShowMapUsingLatLng()
           '=====================================================
       End If
   End Sub


and ShowMapUsingLatLng Sub is :
VB
Private Sub ShowMapUsingLatLng()
       Dim bmpImage As New BitmapImage()
       Dim mapURL As String = "http://maps.googleapis.com/maps/api/staticmap?" & _
                   "center=" & lat & "," & lng & "&" & _
                   "size=500x400&markers=size:mid%7Ccolor:red%7C" & _
                    lat & "," & lng & "&zoom=" & zoom & "&maptype=" & mapType & "&sensor=false"
       '===================
       'Set Latitude and Longitude
       LatitudeTxtBlck.Text = lat
       LongitudeTxtBlck.Text = lng
       '===================
       ' My.Computer.FileSystem.WriteAllText("E:\a.txt", mapURL & vbCrLf, True)
       bmpImage.BeginInit()
       bmpImage.UriSource = New Uri(mapURL)
       bmpImage.EndInit()

       MapImage.Source = bmpImage
   End Sub


and WPF Map App Project Address is : WpfMapApp

please help me
thanx
Posted
Updated 13-Jan-12 18:29pm
v4
Comments
Sergey Alexandrovich Kryukov 14-Jan-12 0:22am    
Please fix your link at the end -- right now it points to the same very page.
--SA
sinaone 14-Jan-12 0:30am    
link is edited thanx

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