I d like to integrate OSM in GWT. I found this library called gwt-openlayers, but I don t understand how can I make it work with the OSM map.
Can anyone provide me a short example?
I d like to integrate OSM in GWT. I found this library called gwt-openlayers, but I don t understand how can I make it work with the OSM map.
Can anyone provide me a short example?
Make sure you inherit from gwt-openlayers by adding the following to your module file:
<inherits name= org.gwtopenmaps.openlayers.OpenLayers />
Also make sure you bring in the OpenLayers javascript library and OpenStreetMap OpenLayers into your application by adding the following lines in "Application.html" page:
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js"></script>
Then it should a simple thing to create a layer that uses open street maps:
OSM openStreetMap = OSM.Osmarender("Base Map");
openStreetMap.setIsBaseLayer(true);
MapWidget mapWidget = new MapWidget("350px", "350px");
mapWidget.getMap().addLayer(openStreetMap);
GWT-OpenLayersHelloWorld
with OpenStreetMap
The following example works fine for me usingOpenLayers-2.8/OpenLayers.js
andOpenStreetMap.js
as described above:
public void onModuleLoad() {
MapOptions defaultMapOptions = new MapOptions(); MapWidget mapWidget = new MapWidget("800px", "600px", defaultMapOptions); OSM osm_1 = OSM.Osmarender("Osmarender"); // Label for menu LayerSwitcher osm_1.setIsBaseLayer(true); OSM osm_2 = OSM.Mapnik("Mapnik"); // Label for menu LayerSwitcher osm_2.setIsBaseLayer(true); OSM osm_3 = OSM.CycleMap("CycleMap"); osm_3.setIsBaseLayer(true); OSM osm_4 = OSM.Maplint("Maplint"); osm_4.setIsBaseLayer(true); Map map = mapWidget.getMap(); map.addLayer(osm_1); map.addLayer(osm_2); map.addLayer(osm_3); map.addLayer(osm_4); map.addControl(new LayerSwitcher()); map.addControl(new MousePosition()); // map.setCenter(new LonLat(6.95, 50.94), 12); // Warning: In the case of OSM-Layers the method setCenter() uses Gauss-Krueger coordinates, // thus we have to transform normal latitude/longitude values into this projection first: LonLat lonLat = new LonLat(6.95, 50.94); // (6.95, 50.94) --> (773670.4, 6610687.2) lonLat.transform("EPSG:4326", "EPSG:900913"); // map.setCenter(lonLat, 12); // see http://docs.openlayers.org/library/spherical_mercator.html RootPanel.get().add(mapWidget); }
you find the current version of gwt-openlayers here: http://sourceforge.net/projects/gwt-openlayers/
I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...
I recently deployed inadvertently a debug version of our game typrX (typing races at www.typrx.com - try it it s fun). It was quickly corrected but I know it may happen again. After digging on ...
Is there a way in GWT to check if the browser running is supporting Flash?
My code works fine in IE 8, but on firefox 3.5, the javascript fails to load. I used firebug to figure out why, and the error I get is (GWT detailed mode) My suspicion is that some style is not ...
I ve been stumped for a while trying to figure out why my GWT demo app isn t working in hosted mode so I went back and downloaded the Google Web Toolkit again, unzipped it and simply went to the ...
Does anyone know how to disable the tool-tip boxes that popup when a Google Visualizations chart is clicked (Selected)? Following the sample code at Getting Started with Visualizations, the "...
I have a GWT 1.7 application and I want to upgrade it to GWT 2 Milestone 2. The application uses 2 big external CSS files. In GWT 1.7 I had a public folder and put both the CSS files in the folder and ...
This is a general question concerning technology decisions for a product development. My aim is to develop a web based remote support (desktop sharing application) with audio and video communication. ...