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 example shows what such a field definition should look like:

<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 that geocode namespace declared 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:service-provider>
            com.escenic.geocode.service.impls.GoogleServiceImpl
          </geocode:service-provider>
          <geocode:map-provider>
            com.escenic.geocode.studio.mapviewer.impls.GoogleMapsViewerImpl
          </geocode:map-provider>
          <geocode:google-api>
            <geocode:api-key><!-- your Google API key --></geocode:api-key>
            <geocode:registered-url><!-- your Google API registration URL --></geocode:registered-url>
          </geocode:google-api>
        </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 example 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.

geocode:service-provider

Must be set to the fully qualified name of a class that implements the abstract class com.escenic.geocode.service.api.GeocodeService and com.escenic.geocode.service.api.ReverseGeocodeService. The specified class is instantiated and used for address- and coordinate-based searches performed by the user. The default implementation shipped with the plug-in is com.escenic.geocode.service.impls.GoogleServiceImpl, which makes use of services provided by Google.

geocode:map-provider

Must be set to the fully qualified name of a class that implements the abstract class com.escenic.geocode.studio.mapviewer.api.AbstractMapViewer The specified class is instantiated and used to display maps in Content Studio. The map viewer implementation displays geotag markers on the map, and supports drag and drop etc. The default implementation shipped with the plug-in is com.escenic.geocode.studio.mapviewer.impls.GoogleMapsViewerImpl, which displays Google maps.

geocode:api-key

If you are using the default geocode:service-provider, then the value you enter here must be a Google API key, obtained by registering with Google as a user of their mapping API.

geocode:registered-url

If you are using the default geocode:service-provider, then the value you enter here must be the URL for which the specified Google API key is valid.

If you have implemented your own service provider class that makes use of a different mapping service, then you can replace the api-key and registered-url elements 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.