Thanks. Is this the code I enter into the Webviewer itself? I am getting a blank Web Viewer. Also FMP seem sto be adding "\"'s to the code. Can you please clarify a bit?
"Set Web Viewer [URL:
\"http://local.google.com/maps?saddr=\" & GetAsURLEncoded ( Trips::PickupAddress ) & \"&daddr=\" & GetAsURLEncoded ( Trips::DropoffAddress )
I wrote pseud script, if you write in webviewer direct
Case ( pickup <>"" and dropoff <> "" ;
"http://local.google.com/maps?saddr=" & GetAsURLEncoded ( pickup ) & "&daddr=" & GetAsURLEncoded ( dropoff )
change pickup and dropoff to your real field names.
So I removed the Set Web Viwer part and change dto code to teh following:
"http://local.google.com/maps?saddr=" & GetAsURLEncoded ( Trips::PickupAddress ) & "&daddr=" & GetAsURLEncoded ( Trips::DropoffAddress )
And I seem to be very close in that it does put my pick up and drop off address in the right place in the map, but it is of course doing the URL encoding, so what I am seeing is this for addresses as an example, which google maps does not seem to like:
1 of 1 people found this helpful
Well I just removed the GetAsURLEncoded () and it seems to be working fine!
So my code is just:
"http://local.google.com/maps?saddr=" & Trips::PickupAddress & "&daddr=" & Trips::DropoffAddress
Seems too simple!!! ;-)
You need to uncheck "Automatically encode URL"
Where do I uncheck that?
Also as I mentioned, it doesn't seem to be necessary to use the function. Am I missing something? I am simply pointing to my text fields that have the addresses and it is working fine without having to use the GetAsURLEncoded ()
Yes, using "Automatically encode" and not encode the parameters work in many cases, especially on English address (it rarely have characters should be encoded, other than space)
Never mind, I see where to uncheck that.
But I am still wondering what if any advantage there is to use the GetAsURLEncoded () function? Just trying to learn here. If sending my text as is works, then do I really need that function?
Generally parameters in URL need to be encoded. Most clear case is, if your data contains "&", without encoding it becomes
name1 can't get "value&1"
So now that this is working I am getting more ambitious! Is there a way for me to get the distance value returned by Google Maps to be directly inputed into the distance field in my layout? That would make the whole process automated which would be great.
I assume I have to somehow parse the xml code returned by Google Maps?
It seems the data are not embedded in the result. (Rewritten URL has data section but may not be what you want)
It is the time to learn API