close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Directions based upon user mobile location

Thread began 7/23/2013 2:38 am by HHar21498653 | Last modified 9/22/2014 4:39 am by Jamie | 1275 views | 21 replies |

HHar21498653

Directions based upon user mobile location

Is there a way to have the directions using the GPS coordinates as the "from" on the mobile as the starting position? (step 5 in the pro map wizard).
I like to use the Pro Maps in a mobile environment, I can enter address where to go but I like to have the driving directions based upon where I am.

If that is not possible is it possible for the user to enter their location and then have Pro Map use that as a "from" address.

Thanks
Henk.

Sign in to reply to this post

Jason ByrnesWebAssist

you would need to hand code the ability for the web page to get the users address:
http://diveintohtml5.info/geolocation.html


as for user entered address, create a form that the user can enter there address, then in the Pro Maps wizard, on the directions screen, click the lightning bolt next to each of the direction elements and select the corresponding form elements.

Sign in to reply to this post

CraigRBeta Tester

Hi Jason,

just started looking at this.

I can extract the geolocation using the code on the google developer site

https://developers.google.com/maps/documentation/javascript/examples/map-geolocation

However the pro maps for google wizard does not cater for co-ordinate input.

Is there a way around this ?

Sign in to reply to this post

Jason ByrnesWebAssist

once you have the latitude and longitude, you can lookup the corresponding address, for example:
http://maps.googleapis.com/maps/api/geocode/json?latlng=42.5,%20-70.89&sensor=true';


you could use that result to pre-populate the address fields in the address form.

i found an example from a google search search for:
get address from html5 geolocation


http://techslides.com/html5-geolocation-address-form-filler/

Sign in to reply to this post

CraigRBeta Tester

Thanks Jason, - i couldn't get the demo to work, but I got the idea.

I used the url you provided - so I can retrieve a json file using co-ordinates, and from the array, i can recover a postcode.

One issue i came across is that the array generated from the json does not always seem to have the same number of elements,, is there a way to always be able to select a postcode ?

eg, in this code snippet

$geoCodeURL = "http://maps.googleapis.com/maps/api/geocode/json?latlng=".$lat.",%20".$long."&sensor=true"; 
$result = json_decode(file_get_contents($geoCodeURL), true);
@session_start();
$_SESSION['retrievedpostcode'] = ($result['results'][0]['address_components'][4]['long_name']);



gives me the postcode, for a particular UK address, but this array value (4) is not a postcode on the url you provided

Other than this, i have a working example, just needs a bit of tidying

Sign in to reply to this post

Jason ByrnesWebAssist

honestly, Craig, I dont know, this would fall under the premiere support category.

Sign in to reply to this post

CraigRBeta Tester

Thanks Jason,

Looks like you can restrict the values returned in the url, which may do the trick.

https://developers.google.com/maps/documentation/geocoding/#reverse-restricted

Sign in to reply to this post

Jason ByrnesWebAssist

ok, cool.

Sign in to reply to this post

CraigRBeta Tester

Please test

Ok, still work in progress, but I have a working version.

If this solution is sufficiently robust, I may write a tutorial.

Here is the page,

http://whitehouse.forthwebsolutions.com/findus.php

the option to 'Get Directions from current location' is only visible when the browser window is 768px or lower (ie mobile devices)

Grateful if anyone is prepared to give it a go, and let me know if it works ok.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

Didn't work for me, but then I am in the US so driving Directions to the UK may be difficult.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...