Last updated November 7, 2008. Created by AlxM on January 12, 2008.
Edited by scor, pkej. Log in to edit this page.

This howto will help you create a simple method for your clients to add locative information to a travelogue. I've been fiddling with a lot of options for doing this, including using feeds with gmap macros. Though gmap macro feeds have the advantage of offering specific marker types for the different feeds, I ended up using a method which does away with that feature, but gains tremendously in usability, due to the fact that the writer doesn't need to know the exact feed syntax and gmap macro syntax to make it work.

For this howto you will need the following modules:

Location
The module needed for adding a location to a node.
Gmap
The gmap module includes the "Gmap location" module which lets you select the location used by the location module via a map.
Gmap addons
A module which contains the Gmap CCK field. The gmap_cck_field can use a nodereference field in the same node type as the gmap_cck_field itself is part of.
Content Creation Toolkit
A module which lets you create your own node types, very versatile, there are lots of tutorials on most aspects of this module available. Do a few searches.
Node Relativity
You will need this to create parent child relationships between nodes.
Viewfield
A module which lets you reference a view from a field in a CCK node

After downloading, installing, setting up permissions, configuring default settings and otherwise following the instructions included in the above modules you do the following. Some of the modules above might depend on other modules. You will have to download them if there are any listed as

If I anywhere skip any parts of an input form it means I don't care about those settings and it is up to you to decide what fits best for your site.

First you create a new node type (/admin/content/types/add) "Point". A point will be the nodes which can contain a latitude longitude for use in location. Almost at the top of the page, just under page title, you will find a collapsed field called "Locative information". Click on that field and change both the "Maximum number of locations allowed for this type.:" and "Default number of location forms:" to 1. Then select "Do not collect..." in all of the radio groups below, they are labeled "Location names:", "Street locations:", "City names:", "State/Province names:" and "Postal codes:". These fields will just clutter your input form and for most locations around the world they wont work out of the box. Leave the "Country names:" as is.

Give the datatype a "Name" (Point) and a "Type" (point_via).

Save the node type by pressing "Save content type".

That's all we need for this node type. If you want to add images into the node then add the module image_attach to get a javascript enabled input filter.

Now you need to create two more node types, they will use exactly the same settings as the above, except the names will be "Start Point" and "End Point", and their type names will be "point_start" and "point_end".

Creating these three different node types will allow you to set different markers in the gmap_addons module for the different node types. Thus we can have a green marker for the start node, a blue marker for the end node and all the point in between can have the route marker.

To configure this go to "/admin/settings/gmap_location" and scroll down to the "Markers per content type" group at the bottom. Select the correct markers for each of the three recently created data types.

Then make a new node type. We will call this "Travelogue". In this node you do not change anything in the "Locative information" field set. Give it its name and type. Then press "Save content type".

The next step is to create the node relationships in the "Node Relativity" module. Go to "/admin/settings/relativity" and into the "Global Options" group. Select the four data types we've created and "Save Configuration".

When the page reloads you will have four collapsed groups, for the points select "Any" for the "Parental Ordinality" and "none" for the "Allowable Child Node types".

For Travelogue you select the three point types for "Allowable Child Node types".

Now you need to set the advanced settings of the "Node relativity"-module (http://samipath.kulturarkitektene.no/admin/settings/relativity/advanced). In the "Options for Travelogue (travelogue) nodes" group you set the following:

End Point Child Ordinality for Travelogue Parents:
1

Point Child Ordinality for Travelogue Parents:
any

Start point Child Ordinality for Travelogue Parents:
1

Thus every Travelogue will be allowed to have one start point, one end point, and as many points as you would like inbetween.

Now you can create a new Travelogue (/node/add/travelogue). Just fill it out with some random content. After posting it the "Node Relativity" module will have added a group called "Link Operations". You will be able to exist existing points, or create new ones.

Go ahead and create a "Stat point" by clicking "Create new Start Point".

Select a location and name for that point, and return to the Travelogue after saving the node.

Notice that you no longer have the option to create a new Start Point, only Point and End Point is available. You will also see that you can Remove Start Point, if you want to.

Add an End Point and a few Points.

Take a note of the Travelogue node id. In my system it is 1, since it is the first node I made on a blank system.

Next step is to create a view for showing the points on a map. Go to /admin/build/views/add to start creating the relevant view.

I called mine "children_locations" Then I opened the "Page"-group and checked the "Provide Page View" check box.

The "URL" I called "children/$arg". Arg will be used to select the parent node id of whoose children we're interested in.

Select "Gmap View" from the "View Type:". Give the view a "Title", I called mine "View all children of a node".

Uncheck the "Use Pager"-checkbox. Set "Nodes per Page" to "0".

Go to the "Fields"-group and add at least "Node: Title", "Location: Latitude" and "Location: Longitude". I also added "Node: Body" and "Node: Link to node".

That's the data which will be shown when popping up info about the markers on the map.

The final step is to add an argument. Open the "Arguments"-group and add an argument of the type "Relativity: Parent Node ID".

Save the view and go to "/children/1" (use the Node ID number of the travelogue item you made earlier) to verify that you get up a map with the node types you made. You will see three different marker types, the green, the blue and the route, which is green with a "play" icon.

The next step is to add the view into the travelogue node. We need to add the "viewfield" to the data type. Go to "/admin/content/types/travelogue/add_field" to start adding a field.

Select "View field->Select List" and give the field a "Name". I called mine "map_view".

Give the field a "Label". I called mine "Map". Select the "Force default" checkbox in order to stop users from being able to change the argument, which we will input at the bottom of the page. In the "Data settings"-group, select Required. Choose our view "children_locations" from the select list at the bottom of the page and enter "%nid" as the argument, then press "Save field settings".

Now we need to set the display settings, so go to the "Display fields" tab "/admin/content/types/travelogue/display". Select "Label"="", "Teaser"="" and "Full"="Gmap view".

Press "Submit".

Go to the travelogue we made earlier and see that there is a map inside the node.

More work is needed, first and foremost the popups when clicking the markers needs to have a better layout, but that's just icing on the cake.

Apart from that I think this is the easiest way for non-drupal experts to enter the nodes, as the "Node relativity" functionality will create almost a "step-by-step"-process.

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

I believe I have followed this tutorial to the letter - but:

Give the field a "Name". I called mine "map_view". Then select the "Field type". It should be "Google map view->Google map". Press "Create field".
That I did

Give the field a "Label". I called mine "Map". In the "Data settings"-group, select Required, then press "Save field settings".
Here's where I fall apart - I have "Google map" settings rather than Data settings and an empty google map.
Later when I go to display the only option I have for the field is "Default"
Any thoughts on what I did wrong?

You actually don't add a "Google Map" field. When you add the field "map_view" select the "View field" option.

Then you can set the label to "Map" and this field does have a "Data settings" group, so select required. Also at the top under label there is a "Force default" option. I would recommend this as it will stop the user being able to play with the argument, which will just mess up the view.

At the bottom of the page there is a selection list, use this to select the previously made view "children_locations". Then enter %nid as the argument and it works like a charm.

Have now edited this, as the wording does seem to be a bit misleading but otherwise great tutorial.

I have posted at Gmaps and here (http://groups.drupal.org/node/14430#comment-63881) but there was no answer to my question so am posting it here.

First of all, I've successfully created a macro map with 200 points and I found out that it "choked" the website loading time in IE6 so that's not good. I wanted to create a "table" format instead and my hutch tells me that creating a table format would be a good approach when I'm building to 1000 locations (markers).

I followed this "how to" and successfully created a map with CCK, etc.

My question is this... instead of a "start point" and and "end point", would it be possible for me to use this method to just add markers for all over the map? How?

How can this work with import content in csv?

Many thanks.