Geomajas Geocoder plugin documentation

Geomajas Developers and Geosparc

Version 2.1.1


Table of Contents

1. Introduction
1. What does this plugin do?
2. Maven configuration
2. How-to
1. Default Geocoder Widget
2. Default Geocoder Widget without css (no style)
3. Geocoder API
1. Further Configuration

Chapter 1. Introduction

1. What does this plugin do?

This plugin enables searching a location on the map.

The default widget allows the user to type (part of) a location in a text box. When striking the enter key or clicking the magnifying glass, the input is passed to one or more server-configured geocoder services. If they return one result, the full name is displayed and the map is zoomed to that location.

When more than one possible location is returned, the default widget shows the list in a separat window. The user can select the location of choice by clicking. Again, the map is zoomed to the chosen location.

When no location is found, the default widget will show a warning message.

2. Maven configuration

In order to use this plug-in in combination with the client GWT2, the following Maven dependency is required:

<dependency>
    <groupId>org.geomajas.plugin</groupId>
    <artifactId>geomajas-client-gwt2-plugin-geocoder</artifactId>
    <version>2.1.1</version>
</dependency>

This in turn includes a dependency on the Geomajas server project (i.e. geomajas-plugin-geocoder).

Chapter 2. How-to

This chapter shows how to create and use the default Geocoder Widget.

1. Default Geocoder Widget

The default Geocoder widget is class org.geomajas.gwt2.plugin.geocoder.client.widget.GeocoderWidget. The following code creates the Geocoder Widget and defines the position of the widget on the map:

GeocoderWidget geocoder = new GeocoderWidget(mapPresenter);
geocoder.asWidget().getElement().getStyle().setTop(7, Style.Unit.PX);
geocoder.asWidget().getElement().getStyle().setLeft(100, Style.Unit.PX);

Alternatively, the position can be set in the constructor:

GeocoderWidget geocoder = new GeocoderWidget(mapPresenter, 7, 100);

2. Default Geocoder Widget without css (no style)

The geocoder widget can be loaded with empty css classes. This can be achieved by setting the resource bundle factory <emphase>before</emphase> creating the widget:

Geocoder.getInstance().setBundleFactory(new ExampleClientBundleFactoryNoStyle());
// create the widget
GeocoderWidget geocoder = new GeocoderWidget(mapPresenter);

Chapter 3. Geocoder API

Table of Contents

1. Further Configuration

1. Further Configuration

As with most Geomajas plugins, the geocoder plugin has a single class that provides access to all the configurable functionalities within the plugin:

org.geomajas.gwt2.plugin.geocoder.client.Geocoder

This class provides access to the client bundle factory and view factory that are used in the creation of the Geocoder Widget. Both factories can be overwritten by customized classes.