Active
Project:
Get Directions
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
18 Nov 2011 at 12:50 UTC
Updated:
12 Jul 2012 at 21:00 UTC
I would like to build a block which automatically displays directions from the user location (given by the browser HTML5 geocoding feature for anonymous users or by the stored user location for autenticated users) to the current node location.
Such a module should have three sections in this order:
Would it be possible using Get Directions?
Comments
Comment #1
hutch commentedProbably.
From location enabled authenticated users to a location enabled node can be done with function getdirections_u2n_setlocation()
If you have lat/lon use can use
function getdirections_locations()
If you configure Getdirections to use v3 Googlemaps API and use advanced settings and alternate method for displaying the route the map will automatically recalculate if the route is dragged.
Read the README, look at comments in getdirections.api.inc and in getdirections.module and you should be able to get where you want.
I don't know how you would obtain the browser HTML5 geocoding feature information but I imagine that this could be done using javascript to grab it and ajax to send it to a function on the server.
Comment #2
cesareaugusto commentedFirst, thank you really much for your quick support!
This is the code I put in my custom block.
Of course it doesn't work. The W3C method for getting user location by the browser should be getCurrentPosition().
What should I change?
Comment #3
hutch commentedgetCurrentPosition() is a javascript function, see http://dev.w3.org/geo/api/spec-source.html for the specifications.
You can't insert a javascript function straight into a php function ;-)
Remember that browser location only makes sense on mobile devices, my main workstation returns a location that is several hundred miles away....
You might find more howto by googling.
http://jquery-howto.blogspot.com/2009/04/get-geographical-location-geolo...
http://code.google.com/p/geo-location-javascript/
Comment #4
ocamp commentedok,
I found this code.
HTML
JS
this simply shows the lat/lon in a location div on a page.
would you be able to implement a current location to node function.
Or how can I use getdirections/to/node/1 and auto fil the from field using the lat/lon retrieved from the script?
Comment #5
hutch commentedTry "getdirections/latlon/from/lat,lon/somewhere"
Where lat,lon is a latitude,longitude pair and "somewhere" is a description of 'from'
Comment #6
ocamp commentedok so I can use /getdirections/latlon/from/(lat,lon)/me
to get the current users postion called me.
How can I put a to destination on now. like
/getdirections/latlon/from/(lat,lon)/me/to/1
where 1 is node/1
Comment #7
hutch commentedYou could put "the current location" instead of "somewhere". You do not have a node/[nid], you only have whatever navigator.geolocation returned and that could be anywhere.