The following are instructions on how to create a OpenLayers WKT CCK Field.

Please note that this method of storing geographical information is not very robust, but works decently for basic needs. If you need more flexible methods of storing geographical information, please consider using Geo.

  1. Install the OpenLayers CCK module that comes with the OpenLayers module.
  2. Add a new OpenLayers map preset (or use existing one if more appropriate).
    1. Go to: admin/build/openlayers/presets/add
    2. Depending on your needs, it may make sense to start the map at a specific point and zoom
    3. If you want to add more functionality and style options, you can do so via the “Behaviours” and “Layers & Styles” tabs, such as using different map tile layers and configuring the map UI elements. Please see the Getting Started with OpenLayers for more in depth information.
    4. Please note that in order to style the input features, set the Default Style for the whole map.
  3. Add a new field to a content type. (see CCK for more detailed information on fields).
    1. Choose an OpenLayers WKT field and the OpenLayers Map widget.
    2. For the Input Map Preset, choose the map preset created above. Although not enabled by default, in most cases it probably makes sense to use the Zoom to Layer option; this will make sure that when viewing the node, the map will be showing the added point in the center.
    3. Under Global Settings, choose the usual field settings, and also Feature Types which will determine what kind of features can be inputted into this field.
    4. Go to the Formatters for the field to choose how to display this field when viewing the node.
  4. Go to the add a node of the type that you added the field to. You will see an interactive map to input features on. The below example only had points enabled for the types of features to add.

Comments

itserich’s picture

Thanks, this worked for me.

One minor point, for people new to Drupal, not sure what Formatters refers to in step 3.4 it may be an interface unfamiliar to me, I found "Full node" in the node's Display Fields tab. And I used "Entry Map" the same map created in Step 1.

Also, when trying to create a node, be sure to click the pencil mark in the upper right corner, or moving the mouse will simply move the map and the WKT field will not populate.

To enter an address instead of using a map to find a location, choose widget type OpenLayers Geocoder.

And finally, in the map preset step 2.2, the Centerpoint is entered as long/lat which I think is uncoventional.

This is a good source to confirm a location's coordinates. http://www.itouchmap.com/latlong.html

I need to learn PROXIMITY FILTERING in Views. If you have any advice, please comment or contact. Thanks!

ckng’s picture

Hope this help other.

To center on OL WKT field when using CCK display field,
- preset 'Zoom to layer' won't work.
- It should be set in the Openlayers WKT field CCK settings, let's say CCK field 'map', enable the 'Zoom to layer' under 'Formatter behavior' fieldset instead.

ulissesgrz’s picture

have a question im working with open layers with the google api
and to mak a point o polygon
dont view in the icons to add the WKT