Posted by ChocolateTeapot on March 18, 2010 at 6:09pm
I'd like my users to be able to create a trail (polygon) in a map by clicking various points. Can anyone point me in the right direction please?
Thanks
I'd like my users to be able to create a trail (polygon) in a map by clicking various points. Can anyone point me in the right direction please?
Thanks
Comments
try Mapstraction CCK
Hi,
Take a look at:
http://drupal.org/project/mapstraction_cck
S.
Thanks very much, I'll take a
Thanks very much, I'll take a look.
I think this will do what I
I think this will do what I want, but I can't work out how to use to to allow users to create their own trails.
I've created a content type of Trail and added a field called plot_trail, type Geospacial Data, widget type Mapstraction Map, data type Linestring. I'm able to plot a line, which is exactly what I want, but the co-ordinates aren't being saved.
Can anyone point me in the right direction please?
Thanks.
Help page created
I created a short how-to page. Please let me know what is not clear and I will add the info into the page (if I know the answer).
Thanks, the information is
Thanks, the information is great.
The problem I'm getting now is that once the content has been created, the page shows the text LINESTRING(etc...), rather than a map. I guess I have to create a View to transform the LINESTRING into a map, which I'm struggling with, but I think that's because my View isn't working.
I've created a content type Trail, auto aliased as trail/[title-raw]. I've created a View, just with the Title on it for now. I'm not quite sure how to target the [title-raw] as an argument. For example, a page title is Seven Stiles, which creates an alias of trail/seven-stiles. What would I use as the View path?
Thanks very much for all your help.
how-to updated
I updated the how-to. Please see the steps 6 and 7. Do not use views for basic display of the node. The view is for displaying a combination of multiple Mapstraction objects defined on multiple nodes on one map.
This is just what I want,
This is just what I want, thanks so much.
Is there a way of configuring the map on the add content page? For instance setting the initial point and zoom?
Thanks again.
Setting up default viewport
AFAIK there does not seem to be much you can do when it comes to initial view, but the module creators configured the map to auto-select the optimal zoom and viewport to show all of the drawn-in shapes at the biggest size allowed by the map frame dimensions.
Ok, thanks very much.
Ok, thanks very much.
Trackfield
Although it appears you have solved this, another option might be the trackfield module:
http://drupal.org/project/trackfield
This was designed specifically for recording individual trails, with altitude graphs, etc.
Ability to draw paths was the requirement
Robin, ChocolateTeapot needed ability to draw paths into map by hand:
"...I'd like my users to be able to create a trail (polygon) in a map by clicking various points..."
AFAIK trackfield does not have such a function(?).
Create trail map not displaying
I had this working and then had to leave it for a few weeks. I've now come back to it and updated to the recommended Mapstraction 6.x-2.x-dev and Mapstraction CCK 6.x-1.x-dev. I'm not sure whether it's related to the updates, but I now get
Geocode field
Insert an address to center the map
(which I think is a new feature, great)
Then a blank area where the map field should be
Then Click the controls above the map to switch between edition mode and zoom/pan mode or add a new feature to the map.Draw your feature, double-clicking to finish. You may edit your shape using the control points.To delete a shape, select it and press the delete key.
This is the code that's being created.
<div style="width: 400px; height: 300px;" class="mapstraction_map" id="mapstraction-cck-map-auto-id-field_plot_walk"></div>The map is showing on the node page.
Any idea why my map has disappeared from the create content page?
Any help appreciated, thanks.
Rolled back
I rolled back to the previous version of Mapstraction CCK (6.x-1.x-dev) and I can now see an OpenLayers map. I'll report it as an issue unless anyone has any ideas?
Google Map API
I wrote a custom module for this. Just read the Google Map API and Examples and do alot of Javascript.
In particular, look at http://mapsapi.googlepages.com/poly2csv.htm and how they did their "New Polygon" and "New Line from scratch" function in their context menu (right-click on map).
Basically your creating listener on the GMap for the click event, which will populate a text-field with the comma seperated decimal lat/long coordinates and then do a redraw of the line (aka map overlay). In the hook_form_submit, just parse the coordinates in to a MySQL Well-known Type (ex. LineString) and saving it into the database. The work is about 75% Google/Javascript and 25%Drupal/MySQL. Watchout for NS conflicts on AJAX Library, because Google use Prototype.