Try to implement this, using gwt objects.
You can insert gwt-map js from the normal view, not from EntryPoint.
Here code example:
public MapRootView() {
Maps.loadMapsApi("", "2", false, new Runnable() {
@Override
public void run() {
isApiLoaded = true;
}
});
}
Next method will be called only when this view will be requested.
@Override
public void createView() {
initWidget(uiBinder.createAndBindUi(this));
// TODO add some perfect loading stub
// timer is used because of asynchronous library loaded
Timer apiLoadedTimer = new Timer() {
@Override
public void run() {
// when api loaded just create and add map to the page.
if (isApiLoaded) {
createMapWidget();
mapHolder.setSize("100%", "300px"); // this is very important
that height must be specified (parent div)
mapHolder.add(mapWidget);
cancel();
}
}
};
apiLoadedTimer.scheduleRepeating(1000);
}
For now, you can do whatever you want, because you have mapWidget,
LatLong objects, etc.
private void createMapWidget() {
LatLng kievCity = LatLng.newInstance(50, 30); // Kiev city (I hope,
sarcasm) will be the center
mapWidget = new MapWidget(kievCity, 12); // initialize a widget
mapWidget.setSize("100%", "100%"); // set size for map
mapWidget.addControl(new LargeMapControl()); // add a control for
map
mapWidget.getBounds(); // return you a bounds of currently showing
picture
}
Don't forget about timer - google-map-js loads asynchronously.
On Apr 16, 5:27 am, muggs <muggs...@gmail.com> wrote:
> I'm currently trying out my first gwt app with gwt-map library. I'm
> having problem accessing getLatitude() and other similar methods in
> ClientLocation class. I'm new to gwt and needless to say
> JavaScriptObject, I have tried asking in StackOverflow.com and experts-
> exchange.com but unfortunately I have yet to receive any replies..
> Hopefully this will be the right place to get help ...
>
> Below is a snippet of my code
> ---------------------------------------------------------
> public void onModuleLoad() {
> ClientLocation user = getUser();
> LatLng cawkerCity = LatLng.newInstance(user.getLatitude(),
> user.getLongitude());
> }
>
> private native ClientLocation getUser() /*-{
> return $wnd.jsonData[0];
>
> }-*/;
>
> --------------------------------------------------------
>
> I have tried return $wnd.jsonData but it returned null.
>
> How should I get an instance of ClientLocation so that I can use
> getLatitude() and getLonitude() ?
> Any help or examples will be much appreciated...
>
> gwt-map Library:http://code.google.com/p/gwt-google-apis/wiki/MapsGettingStarted
> API for ClientLocation:http://gwt-google-apis.googlecode.com/svn/javadoc/maps/1.1/com/google...
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment