Lavenderchan
Technical User
Hello,
I am looking to plot point multiple pins in google maps using vba code. I am using this code to plot point one property using lat and long:
The only open source code that I did find that shows multiple plot points is written in vb.net and I am not sure how to convert it or if I should just rewrite my own. Here is the code:
Any help would be appreciated.
I am looking to plot point multiple pins in google maps using vba code. I am using this code to plot point one property using lat and long:
Code:
Private Sub Command92_Click()
On Error Resume Next
If IsNull(Me.Longitude) Or Me.Latitude = "" Then
MsgBox "No Longitude and latitude info found", vbCritical, "Error Info Dailog"
Else
'double address written below after @ to be at centre and 10z are the zooming
Url = "[URL unfurl="true"]https://www.google.ae/maps/place/"[/URL] & Me.Latitude & "," & Me.Longitude & "/@" & Me.Latitude & "," & Me.Longitude & ",10z"
Application.FollowHyperlink Url
End If
End Sub
Code:
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 = "[URL unfurl="true"]http://maps.googleapis.com/maps/api/staticmap?center="[/URL]
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