PDA

View Full Version : Google Maps, inputting destinations



Raygar
03-13-2013, 01:30 PM
Got a scenario regarding Google Maps.
I seen many arcticles about it, but it's a bit complex and over my head. All I want to do is input destinations into the interface from a list I have which is exported to Excel.
Can't post links yet, but the site is just simply google maps.

I have the following code listed below.
Clicking on "Get Direction" isn't an issue.
Clicking on "Add Destination" isn't an issue.
Filling in Rows "A" & "B" isn't an issue, but I can't add in lines for C, D, E, F, etc.
I really don't want to resort to 'sendkeys'.

I seen references to $ID. I'm thinking that's how you do it, but how do you make use of $id?
Example:
<div class="dir-wp" jsattrs="id:'dir_wp_' + $id" id="dir_wp_template" style="display:none">


Sub GoogleMaps()
Dim FieldAddress As Object
Dim FieldAddress2 As Object
Dim FieldCoordinates As Object
Dim BtnDirections As Object
Dim BtnAddDestinations As Object
Dim BtnReset As Object
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")

ie.Visible = True
While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Wend
ie.navigate "google maps"
While ie.Busy
Application.Wait DateAdd("s", 1, Now)
Wend
Application.Wait DateAdd("s", 1, Now)
Set BtnDirections = ie.document.getElementById("d_launch")
BtnDirections.Click
Set BtnAddDestinations = ie.document.getElementById("add_dest")

Set FieldAddress = ie.document.getElementsByName("saddr")
FieldAddress(1).Value = "Start"

Set FieldAddress2 = ie.document.getElementsByName("daddr")
FieldAddress2(1).Value = "End"

BtnAddDestinations.Click
Application.Wait DateAdd("s", 1, Now)


' saddr = start address. daddr = end address. Using array (2), (3), etc doesn't work.


End Sub

Kenneth Hobs
03-13-2013, 07:24 PM
Maybe this approach will suffice.

http://www.vbaexpress.com/forum/showthread.php?t=33373

Raygar
03-14-2013, 04:45 AM
I don't believe this will do the job. It's basically what I've seen everywhere I've googled.
The total distance between 2 locations isn't what I'm looking for.

Inputting a route of 8-12+ specific destinations (drop off areas) and having a visual of that route is what is important.


The start and end location for this is literarly the most unimportant bit of information (the start & end locations are the same).

Kenneth Hobs
03-14-2013, 05:40 AM
Are you wanting screen prints of maps? Try explaining what you want in an excel file with screen prints of an example.

The API that I used in the referenced thread can do more than was shown. See the link that I commented in that thread.

Raygar
03-14-2013, 06:48 AM
Attached is an example.

The most critical part is visual route of the path to take.
I have reports in excel that I want to fill in the destination fields. I'm fine on the Excel side of things. Just can't figure out how to connect to Google Map's rows C, D, E, F, etc.

Kenneth Hobs
03-14-2013, 08:03 AM
So your goal is to use Internet Explorer and navigate to the googlemaps.com URL with all the options set for them and show Internet Explorer to the user?

Getting a static map using an API method would be faster if your goal was to show the user a map image.

Raygar
03-14-2013, 09:24 AM
I saw the Static API. I'm not sure that it's what I'm looking for. I'm trying everything I can to avoid using it.


In a practical sense, a person would take a requested route of about a dozen different regions, each with a dozen stops or so (dozen generated maps, with a dozen destinations each).
The number of people performing the request... lets say that too is a dozen. This occurs each day.

Kenneth Hobs
03-14-2013, 11:40 AM
FireFox has an Element Inspection tool that can help you. The outer HTML for that C field is what you want to get the ID.

e.g.
Set FieldAddress = ie.document.getElementByID("dir_ib_2")
FieldAddress.Value = "C"

Raygar
03-15-2013, 04:17 AM
FireFox has an Element Inspection tool that can help you. The outer HTML for that C field is what you want to get the ID.

e.g.
Set FieldAddress = ie.document.getElementByID("dir_ib_2")
FieldAddress.Value = "C"
Thank you so much. That worked.
I'll have to look at this Firefox tool.

Kenneth Hobs
03-15-2013, 04:46 AM
Of course for the next field you would replace the ID string's 2 with a 3 and so on. The tool is easy. Right click a field and then Inspect Element. Select the drop down arrow and choose the inner or outer HTML.

cheers