Solved

how to open Waze.com/livemap from address saved in DB?

Posted on 2016-08-16
26
152 Views
Last Modified: 2016-09-13
Hi Experts,

Wondering how can I get the following site opened from my Access app with starting From/To addresses.

https://www.waze.com/livemap

I know its possible to do it to mapquest.com and to tripplanner.com, guess there should be a way to get this done to Waze as well.
0
Comment
Question by:bfuchs
  • 14
  • 8
  • 4
26 Comments
 
LVL 57
ID: 41759170
You would start here:

https://www.waze.com/about/dev

  and send formatted URL strings to the site just like you do for mapquest and others.

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41760178
Hi Jim,

For TripPlanner for example I have the following
Private Sub OpenTripPlanner(sOrigin As String, sDestination As String)
    DoCmd.Hourglass True
    Dim ie As Object, frm As Object
    Set ie = CreateObject("InternetExplorer.Application")
    ie.navigate "http://tripplanner.mta.info/MyTrip/ui_web/customplanner/tripplanner.aspx"
    Do While ie.busy Or ie.ReadyState <> 4
        DoEvents
    Loop
    Set frm = ie.Document.Forms(1)

    'Wait 1000
    Wait 300
    
    frm("txtOriginInput").Value = sOrigin
    frm("txtDestinationInput").Value = sDestination
    ie.Document.ParentWindow.execScript ("submitAddresses()")
    ie.Visible = 1  Sub
    DoCmd.Hourglass False

End Sub

Open in new window

Which took me some time to figure out all those names (had to open site switch to inspect code and search for text & buttons names etc..)

While for Mapquest I simply send the following
add = "http://www.mapquest.com/directions/main.adp?go=1&do=nw&rmm=1&pn1x=&a1x=&c1x=&s1x=&z1x=&un=m&cl=EN&qq=hltF3hzNT9tNhURP0HLlhh9UYBmHRqyBceg4Gkon14D8uewLk7pjHQ%253d%253d&ct=NA&rsres=1&1y=US&1ffi=&1l=&1g=&1pl=&1v=&1n=&1pn=&"
    add = add & "1a=" & eAdd & "&1c=" & eCity & "&1s=" & eState & "&1z=" & eZip & "&2y=US&2ffi=&2l=&2g=&2pl=&2v=&2n=&2pn=&"
    add = add & "2a=" & fadd & "&2c=" & fCity & "&2s=" & fState & "&2z=" & fZip & "&r=f"
    'FollowHyperlink add
    Shell "C:\Program Files\Internet Explorer\Iexplore.exe " & add, vbMaximizedFocus

Open in new window


However here for Waze none of them seem to work, the URL gets handled internally so I can not get to see the value expected and there is nothing in code resembling the input boxes I'm looking for.
See attached.

I did look at the developers site and the only thing I found relevant to Access was perhaps the following:
search for address:      waze://?q=<address search term>
But so far wasn't able to figure out how to compose the string in a way that works.

Thanks,
Ben
Untitled.png
0
 
LVL 57
ID: 41760196
I did look at the developers site and the only thing I found relevant to Access was perhaps the following:
search for address:      waze://?q=<address search term>
But so far wasn't able to figure out how to compose the string in a way that works.

I'm sorry, I didn't look at that closely enough.  While it resembles a URL, it's really not.   It's a call to their app, which is installed on a phone.

 In other words, it's all locked down so you can't get at it via a traditional REST API like other sites.

 Your only choice in working with this site would be to invoke an instances of IE via automation, then control it as if you were a user (fill in the search box, click, wait, etc).  That's never easy and is going to take some doing.

Jim.
0
 
LVL 57
ID: 41760200
Looks like their whole focus is phones right now.

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41760263
Your only choice in working with this site would be to invoke an instances of IE via automation, then control it as if you were a user (fill in the search box, click, wait, etc)
Then problem is that even if you open this site manually from a browser, the insertion point will not get to the address text box unless you manually enter in it, not even the enter key or tab gets there..
and therefore code like below will not work.
    FollowHyperlink "https://www.waze.com/livemap"
    Wait 100
    SendKeys "My Address"

Open in new window


Thanks,
Ben
0
 
LVL 57
ID: 41760736
Ben,

<<Then problem is that even if you open this site manually from a browser, the insertion point will not get to the address text box unless you manually enter in it, not even the enter key or tab gets there..
and therefore code like below will not work.>>

  Yes, well working with a site like that which is interactive is a little more complex.   You have to work with the web page.   IE maintains a document object, which you need to hunt through to find the form, the control to fill, and the button to click.

 While not impossible, it can be an adventure because of all the different ways web sites work.  One is not like another.

 You might get away with send key's in some cases, but then you might need to resort to the above.   Here's an old thread that shows what I'm talking about:

https://www.experts-exchange.com/questions/28358843/using-ie-document-getElementById-to-submit-form-or-click-logon-button-in-vb6.html

Just depends on how the page is constructed.

 But for a start, see if hitting the tab key jumps you to the box.

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41761584
Hi Jim,

But for a start, see if hitting the tab key jumps you to the box.
Good news, although at first glance this didnt seem to work, I realized now that it takes about a dozen of tab hits in order to get there..

Guess I'm better of starting with this while using the send keys option as it seems to be the easiest path..

Will keep you posted.

Thanks,
Ben
0
 
LVL 57
ID: 41761596
OK.   Let me know if you want to explore the other route.

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41761652
Perhaps.

Are you referring to the way Triplanner works?

Something like this
    Set frm = ie.Document.Forms(1)
   
    frm("txtOriginInput").Value = sOrigin
    frm("txtDestinationInput").Value = sDestination
    ie.Document.ParentWindow.execScript ("submitAddresses()")

Open in new window


I did try looking for this but was not successful yet.
for example (under view-source:https://www.waze.com/livemap) nothing that starts with either txt or address showing up there..

Also tried searching for things under site with Inspect (see attached), nothing there resembling those input boxes.

Maybe I need some pro guidance on how to proceeded with this.

Thanks,
Ben
Untitled.png
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41761935
Hi Jim,

Just updating.

Looks like behavior of this site keeps changing, earlier today when tested this with chrome it worked as stated above, however now with chrome I cant to see the text boxes meant for entering search address.

While when I test this with IE then the tab key gets all over the page except for there..

Will not be in office tom, hope to resume next week.

Have a nice weekend!

Thanks,
Ben
0
 
LVL 57
ID: 41762230
Ben,

SendKeys is just too unreliable for something like this.

You'll need to load the web page in an instance of IE and control it via automation.

<<Have a nice weekend!>>

 Going to try, but it's going to be another work weekend :(

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41765958
Hi Jim,

but it's going to be another work weekend :(
Such a pity you don't allow yourself some kind of vacation-:(

So far I could not find a way to accomplish it, as you said send keys is not the right tool for this task and the for the other way, I tried yesterday again w/o much success..

At the moment I'm waiting for someone in office with more web programming experience to give me a hand.

Will let you know how things proceed..

Thanks,
Ben
0
 
LVL 57
ID: 41766802
Ben,

<<Such a pity you don't allow yourself some kind of vacation-:(>>

 Actually one of the reasons I worked; I am rolling up on a vacation<g>

<<Are you referring to the way Triplanner works?>>

  Yes, that was exactly what I was talking about.  I just re-read the thread and realized you were already most of the way there!

 So depending on how the web page is constructed, you may or may not use the forms() collection in the document.  This is where your web developer can help you.   Also you can try using the developer tools in IE (Shift/Ctrl/I  - that's the letter I on the end) and it will show you what is being used as you navigate a page.   You can also check out a program called Fiddler, which gives you a ton of info (might want to wait for the web dev on these though).

 Depending on how it is constructed, you may have to use on of the following:

getElementsByTagName("")
getElementsByClassName("")
getElementsByName("")
getElementsById("")

 to get at the various elements on the page.  Once you have the correct element, then you will be able to call its methods and "click" a button, or fill in the text.

 So for example, if the inputs were all tagged by "Input", you could do this:

Set objInputs = IE.Document.getElementsByTagName("input")

For Each ele In objInputs
    If ele.Title Like "Get start point" Then
        ele.Click
    End If
Next

 Good news is that your really almost there!

Jim.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 3

Author Comment

by:bfuchs
ID: 41768038
Hi Jim,

I did play around with all what you suggested, but still far away..

for example
Private Sub OpenWaze()
    Dim ie As Object, frm As Object
    Dim objInputs As Object, ele As Object
    Set ie = CreateObject("InternetExplorer.Application")
    ie.navigate "https://www.waze.com/livemap"
    Do While ie.busy Or ie.ReadyState <> 4
        DoEvents
    Loop
    'ie.Visible = 1
    Set frm = ie.Document.Forms(1)
Set objInputs = ie.Document.getElementsByTagName("Input")

For Each ele In objInputs
    If ele.Title Like "Get start point" Then
        ele.Click
    End If
    Debug.Print ele.Title

Next
End Sub

Open in new window

I see the loop above had some cicles, however on immediate window nothing got printed?!

Also downloaded Fiddler and tried my luck but again..-:(

(might want to wait for the web dev on these though).
Yeh, thats sounds like my best option..

Good news is that your really almost there!
Will let U know when I get there..(Interesting Waze has directions to all over the world, why cant they get me there?-(:

Thanks,
Ben
0
 
LVL 57
ID: 41768539
On this:

<<Set objInputs = ie.Document.getElementsByTagName("Input")>>

Just to be clear "Input" is not something that is standard, but what the developer of the page decided to tag the elements with.   The tag used in the page your looking at may be totally different or they might not even be tagged at all and you'd need to use one of the other Get methods.

 If I had the time at the moment, I would dig into the page and see what I could come up with, but since time is short and you have access to a web developer, that's probably the best way to go (web is not my thing either, but it's something I always like to try and learn a bit, so I'd take a stab at it if I had the time).

Make sure that when you do figure it out, you post a comment and then accept that as the solution.

Jim.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41769728
Hi,
The tag used in the page your looking at may be totally different or they might not even be tagged at all and you'd need to use one of the other Get methods.
It happened to be I tried with the other methods as well and the only one I saw did had some elements was the TagName with "input", and therefore I wondered why nothing showed up in my debug window..
Make sure that when you do figure it out, you post..
Don't worry I will.

Thanks,
Ben
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41788492
Hi Jim,

So far I dint got any help yet regarding this from our developer:(

What do you suggest, maybe I should post as Gig project?

Thanks,
Ben
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 41795126
Waze url does not support the address. It however supports geo coordinates as parameters. You can use (another) public webservice to find the coordinates of your address, and then use them to build the URL for Waze.

Solutions based on sendkeys probably would be problematic since waze website is using dynamic lookup (ajax or something) of the entered address as you type.
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41795135
Hi Vadim,

Which means that you have to use public webservice to find the coordinates of your address
Can you post example of this?

Thanks,
Ben
0
 
LVL 40

Accepted Solution

by:
Vadim Rapp earned 500 total points
ID: 41795146
I don't have ready-to-use one, but there are public web services that do it, for instance google places API. Here's a list: http://free-web-services.com/web-services/geo/location-info/ . How you use them, depends on their terms, some probably will require registration for a developer key, some will not. Needs to be researched. The quality of their lookup also may vary greatly.

So the application would probably use xmlhttp object to send the request with the address; receive and decode the response; if the lookup was successful, extract from the response latitude and longitude, build the url, and finally use either application.followhyperlink, or wscript shell object to open it up in default browser (the easiest part :-)
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41795214
OK, started working on it, will let you know how things proceed..

Thanks,
Ben
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41797156
Hi Vadim,

Excuse me for asking this..but as I am not familiar with how Gigs works, if I choose this path will you provide the full code how to get this accomplished?

(I uderansand that by regular posts the experts mainly suggest ideas and point to right direction, and its up to the asker to do further research or perhaps ask additional questions..So for the matter of this post you definitely provided the correct answer, however in terms of Gigs I'm wondering what is the norm?)

Thanks,
Ben
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 41797172
Sure, you basically hire a freelancer to do the job. You define yourself what you expect - in this case probably the code to accomplish this. Once you get the result, you release the payment.

In this case it probably would be a sample Access database with the form that would accept the address, and in the end opened the link. The database shouldn't be compiled so you'd see the code. Also you would be expected to register as a developer for google API and provide the freelancer with your key assigned by Google.
1
 
LVL 3

Author Closing Comment

by:bfuchs
ID: 41797183
Excellent Vadim,

Thank you!

PS, Perhaps you have a solution for the other open question I posted on the Gig (regarding tripplanner)?
0
 
LVL 3

Author Comment

by:bfuchs
ID: 41797256
Hi Vadim,

Why did you delete your solution over there?-:)
0
 
LVL 40

Expert Comment

by:Vadim Rapp
ID: 41797286
because I overlooked the fact that it was not just a url, but POST form with parameters. You can now read the updated solution, unfortunately opposite to the deleted one (which was simply createobject("wscript.shell").run "http://www.somewebsite.com")
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to count occurrences of each item in an array.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now