×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

GET street address by lat and lng

GET street address by lat and lng

GET street address by lat and lng

(OP)
My code:
Private Sub APRI_LAT_LNG()

STRADA = LAT & "," & LNG

Me.WebBrowser1.Visible = True
Me.Text1.SetFocus

Me.WebBrowser1.Navigate "https://dev.virtualearth.net/REST/v1/Imagery/Map/R..." & STRADA & "/17?mapSize=640,480&pp=" & STRADA & ";8&mapLayer=Basemap,Buildings&key=" & BINGKEY

Do Until WebBrowser1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

Me.CZOOM.Enabled = True

Me.WebBrowser1.Document.body.Style.border = "none"
Me.WebBrowser1.Document.body.Scroll = "no"
Me.WebBrowser1.Document.body.setAttribute "scroll", "no"

Me.Text1.SetFocus

End Sub

possible to return in MyVarStreet the name of the nearest street, the lat and lng value?

use for test:

lat=40.674700
lng=14.510800

is a street based city=NAPOLI>countryPIMONTE>zipcode>80050

RE: GET street address by lat and lng

You can certainly get what Bing calls 'location data; from a lat and long - but not sure if location data contains street names.

RE: GET street address by lat and lng

(OP)
strongm, is important, in other case...

RE: GET street address by lat and lng

(OP)
https://docs.microsoft.com/en-us/bingmaps/rest-ser...

for strong...

with http://dev.virtualearth.net/REST/v1/Locations/42.7...

return:

<Response xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/search/local/ws/rest/...">
<Copyright>Copyright © 2022 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
<BrandLogoUri>http://dev.virtualearth.net/Branding/logo_powered_...;
<StatusCode>200</StatusCode>
<StatusDescription>OK</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>7a581d502a7b45c09ec473f7bbd7ab1c|DU00002782|0.0.0.1</TraceId>
<ResourceSets>
<ResourceSet>
<EstimatedTotal>1</EstimatedTotal>
<Resources>
<Location>
<Name>Frazione Morgnano 25, 06049 Spoleto Perugia</Name>
<Point>
<Latitude>42.778046</Latitude>
<Longitude>12.6879169</Longitude>
</Point>
<BoundingBox>
<SouthLatitude>42.774183282429327</SouthLatitude>
<WestLongitude>12.680900499518883</WestLongitude>
<NorthLatitude>42.78190871757068</NorthLatitude>
<EastLongitude>12.694933300481116</EastLongitude>
</BoundingBox>
<EntityType>Address</EntityType>
<Address>
<AddressLine>Frazione Morgnano 25</AddressLine>

<AdminDistrict>Umbria</AdminDistrict>
<AdminDistrict2>Perugia</AdminDistrict2>
<CountryRegion>Italy</CountryRegion>
<FormattedAddress>Frazione Morgnano 25, 06049 Spoleto Perugia</FormattedAddress>
<Locality>Spoleto</Locality>
<PostalCode>06049</PostalCode>
</Address>

<Confidence>High</Confidence>
<MatchCode>Good</MatchCode>
<GeocodePoint>
<Latitude>42.778046</Latitude>
<Longitude>12.6879169</Longitude>
<CalculationMethod>Rooftop</CalculationMethod>
<UsageType>Display</UsageType>
</GeocodePoint>
</Location>
</Resources>
</ResourceSet>
</ResourceSets>
</Response>

how to get the bold info?

RE: GET street address by lat and lng

Why do you want all of the bold text when your original query relates to simply getting the street address?

Now, if it is just the address line you need, then some simple XML-extracting code will do the trick. The following assumes you have a form with a textbox containing your good, well-formed XML response

CODE -->

Option Explicit

Private Sub Command1_Click()
    MsgBox GetAddressLine(Text1.Text)
End Sub

Public Function GetAddressLine(myXMLString As String) As String
    Dim objXML As New MSXML2.DOMDocument
    
    If objXML.LoadXML(myXMLString) Then
        ' Get first match. And remember that XML is case-sensitive
        GetAddressLine = objXML.SelectSingleNode("//AddressLine").Text
    Else
        ' oops - XML failed to load
    End If
End Function 

(oh, and by not surrounding your examples with TGML tags that prevent parsing, your links get modified for display, e.g we see

http://dev.virtualearth.net/REST/v1/Locations/42.7...

versus the same link surrounded by e.g. Pre tags:

http://dev.virtualearth.net/REST/v1/Locations/42.778200,12.687900?o=xml&key=mykey 
)

RE: GET street address by lat and lng

(OP)
TKS STRONGM,
but wath is the parameter in bold, MsgBox GetAddressLine(Text1.Text)

RE: GET street address by lat and lng

Quote (strongm)

a textbox containing your good, well-formed XML response

RE: GET street address by lat and lng

(OP)
strongm
i use

.....

XMLQUERY = "http://dev.virtualearth.net/REST/v1/Locations/" & LAT & "," & LNG & "?o=xml&C=IT&key=" & BINGKEY

With CreateObject("MSXML2.XMLHTTP")

.Open "GET", XMLQUERY, False
.send

Do While myXML.ReadyState <> READYSTATE_COMPLETE
Sleep (100)
Loop

myXML.loadXML .responseText 'raw xml
Set nodes = myXML.selectNodes("//*")

MsgBox GetAddressLine(?????)

.....

RE: GET street address by lat and lng

So, in your code (or more accurately my code, since it looks to be an extract from my example in thread222-1807492: inser map from url of 18 months ago) myXML is the same thing as objXML - an MSXML2.DOMDocument object with XML loaded

Sop you don't need my function (which assumed you had TEXT that you wanted to work with as per your post 2 Jun 22), just:

MsgBox objXML.SelectSingleNode("//AddressLine").Text

By the way - just a reminder: my posts here are NOT production code; they are examples of possible solutions. They do not have error checking, bounds checking, or even include simple checks for valid return values. The idea is that you take the example and figure out how to best use it in your code. I point this out because if the XML response from Bing does not have AddressLine as a node in the returned XML both my original function and the above code will error - and, sorry Sal21, I have no intention of spending my time talking you through error handling.

RE: GET street address by lat and lng

Hello?

RE: GET street address by lat and lng

(OP)
sorry strong i'm busy (inFamily)

RE: GET street address by lat and lng

Still busy?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close