1

I'm using an OpenLayers wrapper for GWT, called GWT-OpenLayers

On user reference page it says that you need to add a reference on both files, gwt.xml and .html

like this on xml:

 <inherits name='org.gwtopenmaps.openlayers.OpenLayers'/>

and this on html

 <script src="http://openlayers.org/api/2.11/OpenLayers.js"></script>

GWT-OpenLayers has a showcase, and i'm doing exactly what showcase does. But when app starts and I try to check the source code, I don't see on html, the openlayers script. I've tried to add other's scripts but, unfortunately, the script doesn't appear on source code.
Update 01 - html and browser result:

 <head>
  ...
    <script src="http://www.openlayers.org/api/OpenLayers.js"></script>
    <script type="text/javascript" language="javascript"
        src="GeoStatistics/GeoStatistics.nocache.js"></script>
    <script type="text/javascript" src="ol/OpenLayers.js"></script>
    <script src="http://www.openstreetmap.org/openlayers/OpenStreetMap.js">
    </script>
 </head>

Browser = Chrome enter image description here

As you can see, several script's are add on html, but only one appears.

UPDATE 02 - After compile, still not working I've just compiled my project, and the html still with no script tag.

But I've edited the html and load the project, and I've got the script tag. So, it's some solution, if don't have any other way to generate the html with my script tag, I can just put the tag after compilation.

1
  • Can you provide a source code for your HTML file and Module Java file? Most probably your script node is just removed during GWT init. Commented Jan 3, 2013 at 18:58

2 Answers 2

2

The scripts get loaded into application context. You can use FireFox with FireBug or In Chrome Dev Tools. Adding a screenshot of gwt open layer showcase as seen in FireBugs script tab.

enter image description here

Step 1 - Ensure gwt-openlayers-client is in GWT Project classpath for hosted mode and deploy mode compilation

Step 2 - In gwt module xml file

<inherits name='org.gwtopenmaps.openlayers.OpenLayers' />

Step 3 - In html head tag

<script src="http://openlayers.org/api/OpenLayers.js"></script>
<script src="http://openstreetmap.org/openlayers/OpenStreetMap.js"></script>
<script type="text/javascript" language="javascript"
    src="GeoStatistics/GeoStatistics.nocache.js"></script>

Step 4 -

public void onModuleLoad()
    {
        MapOptions mapOptions = new MapOptions();
        MapWidget mapWidget = new MapWidget( "400px", "300px", mapOptions );

        OSM osm_1 = OSM.Mapnik( "Mapnik" );
        OSM osm_2 = OSM.CycleMap( "CycleMap" );

        osm_1.setIsBaseLayer( true );
        osm_2.setIsBaseLayer( true );

        LonLat lonLat = new LonLat( 6.95, 50.94 );
        lonLat.transform( "EPSG:4326", "EPSG:900913" );

        Map map = mapWidget.getMap();
        map.addLayer( osm_1 );
        map.addLayer( osm_2 );
        map.addControl( new LayerSwitcher() );
        map.addControl( new MousePosition() );
        map.setCenter( lonLat, 12 );
        RootPanel.get().add( mapWidget );
    }
Sign up to request clarification or add additional context in comments.

5 Comments

This is not my problem, my problem is: The script tag doesn't appear at any tool, and this is causing my troubles with this wrapper. As your screenshot shows, the script tag of openlayers is there. But on my app is not.
Does Network tab show request for the js files and show any failed request 404 errors for the js files.
Try 1) Ctrl + SHIFT + DEL . 2) Hosted mode . 3) GWT Compile and Deploy in a Server. Also check with all browsers.
Just cleanup your html script tags in the order i have updated.
Thanks for your help, but the compilation didn't solve the problem.
-1

Found the problem.

GWT plugin for maven its not compiling my main .html(gwt:compile)

But, this is not a real problem because the main html its barely updated, so, just put the new .html on my folder it's a solution, not nice, but a solution.

3 Comments

html does not get updated in any manner by GWT!!!!! and notice you have two OpenLayers.js include in your html file!!!
The two openlayers was a test.
gwt:compile has to update my html. Before this question, that build wasn't updating it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.