Link to home
Start Free TrialLog in
Avatar of bfuchs
bfuchsFlag for United States of America

asked on

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

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.
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

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.
Avatar of bfuchs

ASKER

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
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.
Looks like their whole focus is phones right now.

Jim.
Avatar of bfuchs

ASKER

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
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.
Avatar of bfuchs

ASKER

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
OK.   Let me know if you want to explore the other route.

Jim.
Avatar of bfuchs

ASKER

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
Avatar of bfuchs

ASKER

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
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.
Avatar of bfuchs

ASKER

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
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.
Avatar of bfuchs

ASKER

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
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.
Avatar of bfuchs

ASKER

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
Avatar of bfuchs

ASKER

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
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.
Avatar of bfuchs

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Vadim Rapp
Vadim Rapp
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bfuchs

ASKER

OK, started working on it, will let you know how things proceed..

Thanks,
Ben
Avatar of bfuchs

ASKER

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
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.
Avatar of bfuchs

ASKER

Excellent Vadim,

Thank you!

PS, Perhaps you have a solution for the other open question I posted on the Gig (regarding tripplanner)?
Avatar of bfuchs

ASKER

Hi Vadim,

Why did you delete your solution over there?-:)
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")