Hello!
Basically, a user called "Ombir" helped me create a code which automatically lets me get the GPS co-ordinates (Latitude and Longitude) for a certain street address. So, you just type in the street address and poof - two new columns of GPS co-ordinates. Here's the code:
Now, google's GPS site gives out 4 result quality types for the address you've put in:
1. [FONT="]ROOFTOP[/FONT]
2. [FONT="]RANGE_INTERPOLATED[/FONT]
3. [FONT="]GEOMETRIC_CENTER[/FONT]
4. [FONT="]APPROXIMATE[/FONT]
All of which can be found on this batch geocoding app by ticking the "Result quality" b box: https://www.doogal.co.uk/BatchGeocoding.php
Now, I basically want all results which aren't Rooftop to simply appear as blank spaces or appear as "FAILED" or whatnot. I basically just want the "rooftop" results to appear out of all 4 result types.
In all honesty I have NO idea where to look for the result types so I was hoping someone could help me.
Thanks in advance!
Kenny27
Basically, a user called "Ombir" helped me create a code which automatically lets me get the GPS co-ordinates (Latitude and Longitude) for a certain street address. So, you just type in the street address and poof - two new columns of GPS co-ordinates. Here's the code:
Code:
Sub Geocoding()Dim rng As Range
Dim lat As String
Dim lng As String
Dim ndxla1 As Long
Dim ndxla2 As Long
Dim ndxlo1 As Long
Dim ndxlo2 As Long
Dim url As String
Dim resp As String
Dim req As Object
Const api As String = "Paste Your Api Key Here"
Application.ScreenUpdating = False
Set req = CreateObject("WinHttp.WinHttpRequest.5.1")
Set rng = Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
rng.Replace What:=" ", Replacement:="+"
For Each cell In rng
url = "https://maps.googleapis.com/maps/api/geocode/json?address=" & cell.Value & "&key=" & api
req.Open "GET", url, False
req.Send: resp = req.ResponseText
If InStr(resp, "ZERO_RESULTS") = 0 Then
ndxla1 = InStr(resp, """" & "lat" & """") + 8
ndxlo1 = InStr(resp, """" & "lng" & """") + 8
ndxla2 = InStr(ndxla1, resp, ",") - ndxla1
ndxlo2 = InStr(ndxlo1, resp, ",") - ndxlo1 - 1
lat = Mid$(resp, ndxla1, ndxla2)
lng = Mid$(resp, ndxlo1, ndxlo2)
cell.Offset(, 1) = lat: cell.Offset(, 2) = lng
End If
Next
rng.Replace What:="+", Replacement:=" "
Application.ScreenUpdating = True
MsgBox "Geocoding Completed"
End Sub
Now, google's GPS site gives out 4 result quality types for the address you've put in:
1. [FONT="]ROOFTOP[/FONT]
2. [FONT="]RANGE_INTERPOLATED[/FONT]
3. [FONT="]GEOMETRIC_CENTER[/FONT]
4. [FONT="]APPROXIMATE[/FONT]
All of which can be found on this batch geocoding app by ticking the "Result quality" b box: https://www.doogal.co.uk/BatchGeocoding.php
Now, I basically want all results which aren't Rooftop to simply appear as blank spaces or appear as "FAILED" or whatnot. I basically just want the "rooftop" results to appear out of all 4 result types.
In all honesty I have NO idea where to look for the result types so I was hoping someone could help me.
Thanks in advance!
Kenny27