Monday, November 3rd, 2008

Chess Diagram Builder and Maps Library via GWT

Category: GWT, Mapping

Alexander (aka Sasha) Maryanovsky has been hacking away with GWT, and has some come up with a couple of interesting project.

The first, is a fun chess diagram builder that lets you build out a chess diagram and export it out:

Also, he has created Sasha Maps, an API that abstracts mapping implementations allowing you to plugin your own system (but Google Maps and WMS are implemented).

The appropriate Hello World could look something like this:

  1. package com.maryanovsky.mapdemo.client;
  2.  
  3. import java.util.Arrays;
  4. import java.util.List;
  5. import com.google.gwt.core.client.EntryPoint;
  6. import com.google.gwt.user.client.ui.RootPanel;
  7. import com.maryanovsky.gwtutils.client.UiUtils;
  8. import com.maryanovsky.gwtutils.client.UserEventManager;
  9. import com.maryanovsky.map.client.*;
  10. import com.maryanovsky.map.client.impl.Google;
  11.  
  12. /**
  13.  * The entry point of the Map demo.
  14.  */
  15. public class TutorialDemo implements EntryPoint {
  16.   /**
  17.    * Starts the map demo.
  18.    */
  19.   public void onModuleLoad() {
  20.     List tileLayers = Arrays.asList(new TileLayer[]{Google.NORMAL_TILE_LAYER});
  21.  
  22.     Map map = new Map(Google.MERCATOR_PROJECTION, tileLayers, 0, 17);
  23.     LatLng initialLocation = new LatLng(60.050317, 30.350161);
  24.     int initialZoom = 13;
  25.  
  26.     MapWidget mapWidget = new MapWidget(
  27.       new MapLocationModel(0, 17, initialLocation, initialZoom));
  28.     mapWidget.setMap(map);
  29.  
  30.     UserEventManager eventManager = mapWidget.getUserEventManager();
  31.     eventManager.setDragAction(MapWidget.DRAG_MAP_ACTION);
  32.     eventManager.setDoubleClickAction(MapWidget.ANIMATED_ZOOM_IN_ACTION);
  33.     eventManager.setWheelAction(MapWidget.ANIMATED_ZOOM_ACTION);
  34.     eventManager.setRightClickAction(MapWidget.ANIMATED_PAN_MAP_ACTION);
  35.  
  36.     UiUtils.disableContextMenu(mapWidget.getElement());
  37.     UiUtils.addFullSize(RootPanel.get(), mapWidget);
  38.   }
  39. }

The API gives you interfaces to setup custom maps, actions, overlays, map widgets, and more.

Posted by Dion Almaer at 6:26 am
Comment here

++---
2.9 rating from 10 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.