Add geocode fields to content types

In order to make content items "geocodable" you must add a special geocode field to their content type definitions in the content-type resource. The following examples shows what such field definitions should look like. The exact content of the field definitions depends on which map provider you use. For Google Maps, your field definition should look something like this:

<content-types xmlns="http://xmlns.escenic.com/2008/content-type"
               xmlns:geocode="http://xmlns.escenic.com/2009/studio/plugin/geocode"
               xmlns:ui="http://xmlns.escenic.com/2008/interface-hints"
               version="4">
  <!-- Please note the geocode namespace declaration above -->
  ...
  <content-type name="restaurant-review">
    ...
    <panel name="geocode">
      ...
      <field type="basic" name="com.escenic.geocode" mime-type="text/plain">
        <geocode:geocode-editor enabled="true">
          <geocode:google-api>
            <geocode:client-id><!-- Google Maps API for Business Client ID --></geocode:client-id>
            <geocode:api-key><!-- Google Maps API Key --></geocode:api-key>
          </geocode:google-api>
        </geocode:geocode-editor>
      </field>
    </panel>
    ...
  </content-type>
  ...
</content-types>

For OpenStreetmap on the other hand, your field definition should look something like this:

<content-types xmlns="http://xmlns.escenic.com/2008/content-type"
               xmlns:geocode="http://xmlns.escenic.com/2009/studio/plugin/geocode"
               xmlns:ui="http://xmlns.escenic.com/2008/interface-hints"
               version="4">
  <!-- Please note the geocode namespace declaration above -->
  ...
  <content-type name="restaurant-review">
    ...
    <panel name="geocode">
      ...
      <field type="basic" name="com.escenic.geocode" mime-type="text/plain">
        <geocode:geocode-editor enabled="true">
          <geocode:osm>
            <geocode:nominatim-base-uri><!-- Nominatim Base URI --></geocode:nominatim-base-uri>
            <geocode:reverse-nominatim-base-uri><!-- Reverse Nominatim Base URI --></geocode:reverse-nominatim-base-uri>
            <geocode:tiles-uri><!-- Tiles URI --></geocode:tiles-uri>
            <geocode:tiles-attribution><!-- Tiles Attribution --></geocode:tiles-attribution>
            <geocode:tiles-subdomains><!-- Tiles Sub Domains --></geocode:tiles-subdomains>
          </geocode:osm>
        </geocode:geocode-editor>
      </field>
    </panel>
    ...
  </content-type>
  ...
</content-types>

You must add one such field definition to each content type that you want to be able to geocode.

Note the following:

  • A geocode field must have the name com.escenic.geocode (with all characters in lower case).

  • Geocode fields contain elements belonging to a special geocode XML namespace. You must therefore add a declaration for this namespace to your content-type resource (see the bold text in the examples above).

The geocode namespace elements to be included in the field definition are:

geocode:geocode-editor

This element specifies that the field is a geocode editor field, an contains all the other elements. The enabled attribute must be set to true.

Either geocode:google-api or geocode:osm
  • If you want to use Google Maps as your map provider, then you must add a geocode:google-api element. This element must contain either a geocode:client-id or a geocode:api-key element.

  • If you want to use OpenStreetMap as your map provider, then you must add a geocode:osm element (see http://wiki.openstreetmap.org). This element must contain the following elements: geocode:nominatim-base-uri, geocode:reverse-nominatim-base-uri, geocode:tiles-uri and geocode:tiles-attribution. It may also contain a geocode:tiles-subdomains element.

geocode:client-id

The value you enter here must be a Google Maps API for Business Client ID, obtained by registering with Google as a user of their mapping API. You must specify either client-id or api-key.

geocode:api-key

The value you enter here must be a Google Maps API Key, obtained by registering with Google as a user of their mapping API. You must specify either client-id or api-key.

geocode:nominatim-base-uri

The value you enter here must be the URI of a Nominatim search service, see http://wiki.openstreetmap.org/wiki/Nominatim. To use MapQuest Open, for example, specify the following:

http://open.mapquestapi.com/nominatim/v1/search
geocode:reverse-nominatim-base-uri

The value you enter here must be the URI of a Nominatim reverse search service, see http://wiki.openstreetmap.org/wiki/Nominatim To use MapQuest Open, for example, specify the following:

http://open.mapquestapi.com/nominatim/v1/reverse
geocode:tiles-uri

The value you enter here must be the URI of a tiles provider (see http://wiki.openstreetmap.org/wiki/Tiles). To use MapQuest Open, for example, specify the following:

http://{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png
geocode:tiles-attribution

The value you enter here must be an attribution to OpenStreetMap and the tiles provider you are using (see http://wiki.openstreetmap.org/wiki/Legal_FAQ). To use MapQuest Open, for example, specify the following:

<![CDATA[Data, imagery and map information provided by <a href="http://open.mapquest.co.uk" target="_blank">MapQuest</a>, <a href="http://www.openstreetmap.org/" target="_blank">OpenStreetMap</a> and contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/" target="_blank">CC-BY-SA</a>.]]>
geocode:tiles-subdomains

You may use this element to specify a comma-separated list of subdomains of the tiles provider you use (see http://wiki.openstreetmap.org/wiki/Tiles). To use MapQuest Open, for example, specify the following:

otile1,otile2,otile3,otile4

If you have implemented your own service provider class that makes use of a different mapping service, then you can replace the google-api or osm element with other elements holding whatever identification parameters are required by your chosen service, and program your service provider class to retrieve and use the parameters as required.

For general information about the content-type resource and how to edit it, see the Escenic Content Engine Resource Reference.