Geomajas Geocoder plugin documentation

Geomajas Developers and Geosparc

Version 2.4.2


Table of Contents

1. Introduction
1. What does this plugin do?
2. Maven configuration
2. How-to
1. Default Geocoder Widget
2. Customization of the Widget
3. 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.4.2</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:

GeocoderWidget geocoder = new GeocoderWidget(mapPresenter);

2. Customization of the Widget

An alternative constructor of the GeocoderWidget will take custom views. The first view is the widget on the map; the second view presents different locations in case of multiple result to a search:

GeocoderWidget geocoder = new GeocoderWidget(mapPresenter, customGeocderView,
			customGeocoderAlternativesView);

The position of the widget on the map is set via css class parameter ".gm-GeocoderGadget". By default, the widget is positioned on the left top of the map, with values below:

.gm-GeocoderGadget {
	left: 100px;
	top: 7px;
}

The position can be changed by overwriting these values in your own css file.

3. 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 before 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.