Thursday, February 26, 2009

MapFish: interaction between client and server

I just received a question regarding the communciation between MapFish client and MapFish server. As I gave an answer in french, here is one in english ;-)
MapFish provides a MapSearcher class for querying a map. I will use this sample to describe it's usage (source code can be accessed here).

Let's try to see how it works: the information function "i" located in the toolbar lets the user select some features and show them in a grid.



On the server side, it is needed to have an implemation of the MapFish protocol which will interact with the database. See the summits.py code.

On the client side (all the code can be found in search.html) you need:
  1. to use the MapFish protocol with "protocol = mapfish.Protocol.decorateProtocol({..."
  2. to create a Map searcher: "var mapSearcher = new mapfish.Searcher.Map({..." which will use the protocol
  3. to add the "i" button in the toolbar: "toolbar.addControl(mapSearcher, {..."
  4. to create a grid "new Ext.grid.GridPanel({...", a store "var store = new Ext.data.Store({..." and a store mediator "var searchStoreMediator = new mapfish.widgets.data.SearchStoreMediator({..." to show the result provided by the MapFish protocol in a grid.

4 comments:

yvesm said...

Where's the French version ;-) ?

Cédric@camptocamp said...

Par ici pour les francophones: http://georezo.net/forum/viewtopic.php?pid=129803#p129803

Anonymous said...

I want to use the searcher in my client, too.

But I've got one problem:
In this example a protocol is created.
protocol: new mapfish.Protocol.MapFish({
url: mapfish.SERVER_BASE_URL + 'summits',

What kind of URL do I have to add, that the searcher works with my client, too?

Cédric@camptocamp said...

This is the URL of the REST protocoll developped on the server side.
Maybe a question send to the mailing list would help you to get a good support.