I am going to
demonstrate with this short presentation the use of gwt-maps library with MGWT
technology, and this is about how to develop a mobile application under
Netbeans IDE, for all the mobile phones that supports webkit. The
application will have a simple button component that the user clicks, a map
appears on the screen, positioned to Satu Mare city, where I live.
If you have the
Netbeans IDE ver 7.2 installed on your computer, or any other java editor, just
follow the steps:
- download and install(unzip) to your computer the GWT SDK(google web toolkit)
- if you have Netbeans IDE, download the latest GWT plugin for Netbeans, and install it from Tools->Plugins->Downloaded
- download and install(unzip) the latest version of MGWT sdk library(making gwt work with mobile)
- download and install(unzip) the gwt map library, version 1.1
After these steps just create a web application with Netbeans and use for
example the Tomcat Apache web server for running the program. Creating the
application with Netbeans wizard, you will have the option to add to your project, the GWT sdk, at the end of the wizard, by checking it.
After creating your project, right click on project properties window, and
add the library of MGWT(mgwt-1.1.1.jar) too and also the library of
gwt-map(gwt-maps.jar).
In your project, find the *.gwt.xml
file, open it, and add the following lines to the existing code:
<inherits
name="com.google.gwt.user.User"/>
<inherits name='com.googlecode.mgwt.MGWT'/>
<inherits name='com.google.gwt.maps.GoogleMaps'/>
//if you use firefox
<set-property name="user.agent"
value="gecko1_8"/>
//or for example chrome
<set-property name="user.agent"
value="safari"/>
One more step.... :) add the following java
code to onModuleLoad() procedure in your EntryPoint java file:
public void onModuleLoad()
{
//build some UI
layoutPanel = new
LayoutPanel();
Button button = new
Button("View the MAP!");
layoutPanel.add(button);
//for click event
button.addTapHandler(new TapHandler()
{
@Override
public void onTap(TapEvent
event) {
Maps.loadMapsApi("", "2", false, new Runnable() {
public void run() {
// Open a map
centered on Satu Mare, Romania
LatLng SatuMareCity
= LatLng.newInstance(47.792091, 22.885189);
final MapWidget map
= new MapWidget(SatuMareCity, 2);
map.setSize("100%", "100%");
// Add some controls
for the zoom level
map.addControl(new
LargeMapControl());
// Add a marker
map.addOverlay(new
Marker(SatuMareCity));
// Add an info
window to highlight a point of interest
map.getInfoWindow().open(map.getCenter(),
new InfoWindowContent("The River Somes is here in
Satu Mare"));
final
DockLayoutPanel dock = new DockLayoutPanel(Unit.PX);
dock.addNorth(map,
500);
// Add the map to
the HTML host page
layoutPanel.add(dock);
}
});
}
}) ;
RootPanel.get().add(layoutPanel);
}
Where the compoent layoutPanel is a global variable defined in the
main class file, that implements EntryPoint, and where also the method
above is situated.
LayoutPanel layoutPanel;
You can test your application under your browser, but there are also
emulators on the web which you can use to test mobile applicatons:
If you run, the application above should look like:
Good introduction, thanks
ReplyDeleteWelcome.
Deleteit s not working ,can u give the imorts plzzzzzzzzzzzzz
ReplyDeleteIt is deprecated, try also smartgwt.mobile. Sounds good too.
Deleteok thnks , i tired it and it works,but i want to use gwt-gis to or gwt-geo to build a mgwt apps deployed in android,it s possible ??????
ReplyDeleteI think yes, it is possible, but i was never tried on a real device. If you download the mgwt-map example from my webpage: http://siposlehel.atw.hu you can see the source code too, and the application built(it runs without a web server) on the build directory. Also see the list of api's from http://code.google.com/p/gwt-google-apis/downloads/list.
ReplyDeleteNowadays I work with the technology called codename one for mobile phones. It is a native solution for mobiles, when mgwt and smartgwt are closer to web. See: http://www.codenameone.com/
ok thnks :)
ReplyDeletei have more question lehel :) i am trying to reimplemnted ur project (gwt-phonegap rpc) but unfortunatly it s not working for me (i am using eclipse)can u give me ur generated project(file html and js to deployed directly into android) just to convince my boss that rpc work with gwt-phone-gap
ReplyDeleteIn case of server applications, you should deploy the whole application onto your computer :) with a webserver. Rpc is for remote access...Unfortunately mgwt needs phonegap for rpc, smartgwt.mobile not, as i know...Anyway android has it's own local storage, and GWT also has an interface to local storage, it does not need rpc. See this:
Deletehttps://code.google.com/p/gwt-localstorage-db/
https://code.google.com/p/gwt-localstorage-db/wik/UsingTheApi
For more info, subscribe to google - gwt/mgwt - email groups.
And HTM5 storage :)
Deletehttps://developers.google.com/web-toolkit/doc/latest/DevGuideHtml5Storage
If you download my mgwt-rpc-phonegap example, all you need to run, on your tomcat7 webserver, is the gwt-phonegap library which is downloadable from mgwt's site. And include this in the gwt.xml file:
ook thnks i will try :)
Deletecool lehel, but a have a question...
ReplyDeletedid you try to deploy this app with gwt-phonegap in native android app? if yes, did worked?
Hi. No, not yet, i have no time at the moment, but it is possible, i think. Just read and follow the article:
Deletehttp://www.e-nature.ch/tech/wrapping-mgwt-webapp-with-phonegap-into-a-native-android-app/
Please share your experience. thx.