We're developing a GWT app that makes heavy use of the Google Maps Library. That is, there is always (at lea开发者_开发百科st) one MapWidget
attached to the DOM.
Is it somehow possible to mock out the Google Maps API? We're trying to
- speed up the loading time of the application in development mode
- use development mode in situations without an internet connection to prevent the error
java.lang.RuntimeException: The Maps API has not been loaded
Two ways you can avoid the 'The Maps API has not been loaded' error:
1) Using a simple try / catch:
MapWidget map;
try {
map = new MapWidget();
doSomething();
}
2) Using the GWT AjaxLoader:
import com.google.gwt.ajaxloader.client.AjaxLoader;
AjaxLoader.loadApi("maps", "2", new Runnable() {
public void run() {
doSomething();
}
}, null);
精彩评论