<extend-property name='locale' values='en'/> <set-property-fallback name='locale' value='en'/> <set-property name='locale' value='en'/>Though it looks like a hack (and in fact it really is), but it do work! Now our project has single English locale and compiles in 6 permutations.
Showing posts with label GWT. Show all posts
Showing posts with label GWT. Show all posts
29 June 2010
Setting a single locale for GWT application
One library used to output messages in German when locale was not set explicitly (<extend-property name="locale" values="en"/>).
After we add an English locale to GWT module compilation began to take twice more time than in was before and the count of compilation permutations grew twice time too.
It appeared that we cannot just user . Compilation was just failing with that.
After googling a bit I've found a strange example which was promised to work. And it did worked! :) So, here it is:
12 April 2010
Google maps: getMaxZoomAtLatLng and error 500
When I had to catch zoom level when 'no images available for this zoom level', I thought I had pretty quickly found the solution. But I was completely disappointed when this one didn't work. After some research I've managed to make it work :)
First of all I needed this in GWT application. We were using GWT Maps (1.0.4 by that time) which lack this function as such. So here is how we can bridge this function using JSNI:
class GoogleMapsJsBridgeSample {
/**
* Wrapper function to native call
*/
public void getMaxZoomAtLatLng(MapType mapType, double lat, double lon) {
getMaxZoomAtLatLng(mapType.getPeer(), lat, lon);
}
private native void getMaxZoomAtLatLng(JavaScriptObject mapTypePeer, double lat, double lon) /*-{
var latLng = new $wnd.GLatLng(lat, lon);
mapTypePeer.getMaxZoomAtLatLng(latLng, function(response) {
if (response && response['status'] == $wnd.G_GEO_SUCCESS) {
this@com.company.my.GoogleMapsJsBridgeSample::doSomethingWithMaxZoomAtLatLng(I)(response['zoom'])-*/;
}
});
}
private void doSomethingWithMaxZoomAtLatLng(int maxZoom) {
getMap().setZoom(maxZoom);
}
}
The point here is is NOT using MapWidget.getCurrentMapType() due a bug in gmaps-api (not GWT specific). According to the comments for the issue, problem appears only for hybrid map type, but for satellite and normal it is ok! So you can use to code above in the following manner in GWT:
GoogleMapsJsBridgeSample jsBridge = new GoogleMapsJsBridgeSample(); // ... jsBridge.getMaxZoomAtLatLng(MapType.getSatelliteMap(), lat, lon); // or use MapType.getNormalMap() for street map view
Such issues are sometimes specific to the version of gmaps-api you are using. You can always make sure what particular version is used in your application by outputting G_API_VERSION JavaScript variable.
Changelogs for each gmaps-api version are available at http://mapki.com/
Subscribe to:
Posts (Atom)