Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I want to show a map (google maps) that shows all points of interest (known in a db with their Lat Long) and within a direct distance of a certain point on which the map should be centralized... When the mouse is dragged over such a point, a comment field should be shown. If possible the pointers should be given different colors depending a certain value in the db.

Thx for any sample code.
Posted
Updated 11-Nov-14 4:26am
v2

For Example

VB
Dim Gm As New GoogleMap(LatitudineMinima, LongitudineMinima, LatitudineMassima, LongitudineMassima)
      Dim img As Image
      img = Gm.Image
      If MyGoogleMaps Is Nothing Then
          MyGoogleMaps = img
      End If




Public Class GoogleMap
Private MyLatitudineMinima As Double
Private MyLatitudineMassima As Double
Private MyLongitudineMinima As Double
Private MyLongitudineMassima As Double
Private MySizeW As Integer = 640
Private MySizeH As Integer = 640
Private MyScale As Integer = 1
Private MyZoom As Integer = 14
Private MyMapType As String = "roadmap"
Private MySensor As Boolean = False
Private AddMarker As Boolean = True
Public Sub New(ByVal LatitudineMin As Double, ByVal LongitudineMin As Double, ByVal LatitudineMax As Double, ByVal LongitudineMax As Double)
MyLatitudineMassima = LatitudineMax
MyLatitudineMinima = LatitudineMin
MyLongitudineMassima = LongitudineMax
MyLongitudineMinima = LongitudineMin
End Sub
Private ReadOnly Property Url() As String
Get
Dim Str As String
Str = "http://maps.googleapis.com/maps/api/staticmap?center="
Str = Str & Coordinate.Avg(MyLatitudineMinima, MyLongitudineMinima, MyLatitudineMassima, MyLongitudineMassima).ToGoogle
Str = Str & "&zoom=" & MyZoom.ToString
Str = Str & "&size=" & MySizeW.ToString & "x" & MySizeH.ToString
Str = Str & "&scale=" & MyScale.ToString
Str = Str & "&maptype=" & MyMapType
If AddMarker Then
Str = Str & "&markers=color:green%7Clabel:G%7C" & Coordinate.Avg(MyLatitudineMinima, MyLongitudineMinima, MyLatitudineMassima, MyLongitudineMassima).ToGoogle
End If
Str = Str & "&sensor=" & MySensor.ToString.ToLower
Return Str
End Get
End Property
Public ReadOnly Property Image() As Image
Get
Dim ur As New System.Uri(Url)
Dim Wr As System.Net.WebRequest
Dim St As System.IO.Stream
Wr = System.Net.WebRequest.Create(ur)
Wr.Proxy = System.Net.WebRequest.GetSystemWebProxy
st = Wr.GetResponse.GetResponseStream

Using Br As New IO.BinaryReader(St)
Using fs As New IO.MemoryStream
' Dim buffer(1024) As Byte
Try
Do
fs.WriteByte(Br.ReadByte())

Loop
Catch Ex As System.IO.EndOfStreamException
'finito stream
Return System.Drawing.Image.FromStream(fs)
Finally
St.Close()
St.Dispose()
End Try
End Using
End Using

End Get
End Property


End Class
 
Share this answer
 

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