To embed the getdirections map in a node, I added this

echo getdirections_direction();

Default values were set with hook_form_alter() for the 'from' and 'to'

I am trying to figure out how to get the form to load on page load, so that by default some directions are shown.

Or alternatively, to load an screenshot of the map and div with instructions for driving directions, and then on form load, replacing that with the actual information.

Any suggestions?

Comments

hutch’s picture

Have a look at the functions in getdirections.api.inc, there are several that will load a set of directions.

aufumy’s picture

I looked at the api functions, and saw that most returned a link, I am not sure how to embed that in my node, except as an iframe.

I ended up taking the easier way out by embedding a google map with driving directions into the node
http://thewichitacomputerguy.com/blog/embed-google-maps-drupal-node-with...

brenda003’s picture

I ended up using the getdirections_locations_via() function to get a map automatically displayed with various waypoints from the module file itself.

hutch’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

areikiera’s picture

Version: 6.x-1.3 » 7.x-2.x-dev
Status: Closed (fixed) » Active

Hello! I'm not familiar with how to use functions to get the getdirections map to preload the node's "From" value. I created the block with the code from the very first post, but the "From" value was not automatically preloaded, and I'm not sure if it was supposed to.

Could someone explain in more detail how this is accomplished?

(Using the Location CCK field)

Thanks!

hutch’s picture

Have a look at the comments in getdirections.api.inc and in the README.
For instance:
"getdirections/location/from/[nid]"
Where [nid] is the node id of the location enabled node. Build a link with a path like that and it will have From preset.
If you have Views installed you can have a block that will appear when viewing the node. You can edit the view eg add a display that uses 'from' instead of 'to'.

hutch’s picture

Status: Active » Closed (works as designed)
matiaslezin’s picture

If it's any help, I used getdirections_locations_bylatlon in a block (if you have 2 location cck fields) and added it to the content page of a node. For instance,

 echo getdirections_locations_bylatlon('Mendoza', '(-32.890183,-68.844050)', 'Salta', '(-24.782932,-65.412155)');
hutch’s picture

Almost, but the brackets around the lat,lon sets confuse the javascript and cause it to show a map in china.

$a1 = "-32.890183,-68.844050";
$a2 = "-24.782932,-65.412155";
echo getdirections_locations_bylatlon('Mendoza', $a1, 'Salta', $a2);

This puts it where you intended.

hutch’s picture

I have commited code that removes the brackets if present, so the method described in #9 will also work now.

matiaslezin’s picture

Thanks hutch!

matiaslezin’s picture

I'm having a problem in Drupal 7. I'm using the code:


$origen = db_query("SELECT field_origen_lid FROM {field_data_field_origen} WHERE entity_id = ".$data->nid);
$or = $origen->fetchColumn(0);

$destino = db_query("SELECT field_destino_lid FROM {field_data_field_destino} WHERE entity_id = ".$data->nid);
$des = $destino->fetchColumn(0);

$latitude_origen = db_query("SELECT field_latitud_origen_value FROM {field_data_field_latitud_origen} WHERE entity_id = ".$data->nid)->fetchField();
$longitude_origen = db_query("SELECT field_longitud_origen_value FROM {field_data_field_longitud_origen} WHERE entity_id = ".$data->nid)->fetchField();

$latitude_destino = db_query("SELECT field_latitud_destino_value FROM {field_data_field_latitud_destino} WHERE entity_id = ".$data->nid)->fetchField();
$longitude_destino = db_query("SELECT field_longitud_destino_value FROM {field_data_field_longitud_destino} WHERE entity_id = ".$data->nid)->fetchField();

$a1 = $latitude_origen.",".$longitude_origen; 
$a2 = $latitude_destino.",".$longitude_destino;

echo getdirections_locations_bylatlon('city1', $a1, 'city2', $a2);

Everything should be working, but the map is showing me from the same point to the same point. I've checked the values of the latitudes and longitudes and both are ok. It's like it thinks it's going from the start point to the start point.

Any ideas?

hutch’s picture

I can't spot anything wrong with this.

dropfen’s picture

@mitiaslezin
What do you get, if you write something like

...
$a1 = $latitude_origen.",".$longitude_origen;
$a2 = $latitude_destino.",".$longitude_destino;

dpm($a1);
dpm($a2);

echo getdirections_locations_bylatlon('city1', $a1, 'city2', $a2);

in your code?

matiaslezin’s picture

I'll give it a try later on and let you know.

matiaslezin’s picture

Fatal error: Call to undefined function dpm()

What does that function does?

matiaslezin’s picture

Found the problem! The code was alright. It was something else from my website.

Thanks!