Google Maps GWT API - 2.0.0 - Some big changes...

32 views
Skip to first unread message

aglaforge

unread,
Jan 29, 2007, 9:02:52 PM1/29/07
to Google Web Toolkit
January 29th, 2007 - 2.0.0

- All classes now have real constructors, no more create methods.. If
you upgrade there will be a requirement to update your code.

GLatLng.create(37.4419, -122.1419) becomes new
GLatLng(37.4419, -122.1419)

- Removed some of the GMap2Widget constructors

- Implemented GPolygon

- In hosted mode the GMap2Widget.getMaps() function will check to see
if the Goolge Maps java script is in your HTML and will now give an
error message in the GWT Log if it is missing.
----------------

Features on the road map:

1.) Minor updates to bring the API current on Overlay and misc.
2.) GAbstractOverlay will likely appear to simplify the task of
creating an overlay
3.) Generic GEvent handling (as opposed to the existing canned
handlers that work for 99% of the code)
4.) A check to see if the VML xmlns is included for MS browser support
(not quite sure if this is entirely possible yet).
-----------------


Available for download on SourceForge
(http://sourceforge.net/projects/gwt/). For anyone interested in
helping help please e-mail me (developers, testers, documenters
welcome).


To use the API :


1.) Downlod the most current googleMaps.jar from
http://sourceforge.net/project/showfiles.php?group_id=169331


2.) Add googlemaps_gwt_2_0_0.jar to your project's classpath


2.1) Make sure you modify you project's command files
(Project-shell.cmd and Project-compile.cmd) to reference the
classpath


3.) Add the following line into your project's module:


<inherits name='com.mapitz.gwt.googleMaps.GoogleMaps' />


4.) To the HTML file's HEAD you intend to display a map on add the
google maps java script file along with your key (hopefully this is a
requirement that will go away)


Example:
<script
src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA..."
type="text/javascript"></script>


5.) Work with the API in your code
To get started with the API:


//Instatiate the GMap2Widget
// The following instatiation will default the map to 37.4419,
-122.1419 and zoom level 13 size 300px by 300px
GMap2Widget mapWidget = new GMap2Widget("300", "300");


//Alternative method: Setting your own center value and zoom in
the
constructor
//GMap2Widget mapWidget = new GMap2Widget("300", "300",
new GLatLng(37.4419, -122.1419), 13);


//Retrieve the GMap2 object and start manipulating your map
final GMap2 gmaps = mapWidget.getGmap();


//Add the widget to your GWT UI (You can do this before or after
you call getGmap() now).


gmaps.openInfoWindowHtml(pos, "The center of the world");


6.) Example of adding a map event listeners


GMap2EventManager eventManager = GMap2EventManager.getInstance();


eventManager.addOnMoveStartListener(gmaps,
new GMap2EventMoveListener()
{
public void onMoveStart(GMap2 map)
{

searchStatusText.setText("Move
Started");
}


public void onMoveEnd(GMap2 map)
{
}


public void onMove(GMap2 map)
{
}
}
);


eventManager.addOnClickListener(gmaps, new
GMap2EventClickListener()
{
public void onClick(GMap2 map,
GOverlay


overlay, GLatLng point)
{


searchStatusText.setText("Clicked on " + point.toString());
}
}
);


7.) Example of adding a map marker event listeners
GMarkerEventManager markerEventManager =
GMarkerEventManager.getInstance();


markerEventManager.addOnInfoWindowOpenListener(gmarker, new
GMarkerEventInfoWindowListener()
{
public void onInfoWindowOpen(GMarker
marker)
{

searchStatusText.setText("Info
window open");
}


public void onInfoWindowClose(GMarker
marker)
{
}
}
);


markerEventManager.addOnDragEndListener(gmarker, new
GMarkerEventDragListener()
{
public void onDragEnd(GMarker marker)
{
searchStatusText.setText("On
drag end");
}


public void onDragStart(GMarker
marker)


{
}
}
);


8.) Using the geocoder


GGeocodeAdvancedResultListener gAResult = new
GGeocodeAdvancedResultListener()
{
public void onSuccess(GGeocodeResult result)
{
//Do someting with the results
}


public void onFail(String address, int status)
{
//Do something on the fail
}
};


GFactualGeocodeCache cache = new GFactualGeocodeCache();
GClientGeocoder geocoder = new GClientGeocoder(cache);
geocoder.getLocations("4807 Fern Hollow, Austin, TX, 78731",
gAResult);

aglaforge

unread,
Jan 29, 2007, 9:04:31 PM1/29/07
to Google Web Toolkit

krispy

unread,
Jan 31, 2007, 10:00:50 AM1/31/07
to Google Web Toolkit
aglaforge,

there's a problem with this version when I run the following code:

==============================================


GMap2Widget mapWidget = new GMap2Widget("300", "300");

final GMap2 map = mapWidget.getGmap();
map.openInfoWindowHtml(new GLatLng(37.4419, -122.1419), "The center of
the world");

RootPanel.get().add(mapWidget);
==============================================

the map tiles don't populate correctly and I lose mouse events on the
map (no dragging, etc)

when I change the code to:

==============================================


GMap2Widget mapWidget = new GMap2Widget("300", "300");

RootPanel.get().add(mapWidget);

final GMap2 map = mapWidget.getGmap();
map.openInfoWindowHtml(new GLatLng(37.4419, -122.1419), "The center of
the world");
==============================================

everything works correctly - apparently it's something to do with
changing the parent after creating the GMap2 object.
I've tried both these pieces with the same results on Firefox 2.0 and
IE 7.0

nseb

unread,
Jan 31, 2007, 1:21:15 PM1/31/07
to Google Web Toolkit
I have the same problem , for me the workaround it's to call a
mapWidget().getMap().checkResize().

aglaforge

unread,
Jan 31, 2007, 5:58:32 PM1/31/07
to Google Web Toolkit
I've got a change coming in the next release that *should* correct
that. Also in the next release: full support for GEvent (i.e. you can
make your own event handlers), GOverlay and it's subclass will be
current (show and hide methods), and an abstract GAbstractOverlay to
make custom overlay development simpler.

Release will be released before the end of the week.

> > IE 7.0- Hide quoted text -
>
> - Show quoted text -

krispy

unread,
Feb 1, 2007, 5:07:18 PM2/1/07
to Google Web Toolkit
Thanks - that fixed the problem I was having!

You've put together a great API for everyone - it's helped me out a
lot on my project.

zsu...@gmail.com

unread,
Feb 1, 2007, 11:03:54 PM2/1/07
to Google Web Toolkit
Great API!
But could not work with firefox.

Waiting for new version

aglaforge

unread,
Feb 1, 2007, 11:49:10 PM2/1/07
to Google Web Toolkit
2.1.0 was released yesterday and worked with both IE and Firefox (and
is still working as far as I can tell). Could you please explain your
issue?
Message has been deleted

zsu...@gmail.com

unread,
Feb 2, 2007, 1:43:47 AM2/2/07
to Google Web Toolkit

On 2月2日, 下午12时49分, "aglaforge" <aglafo...@gmail.com> wrote:
> 2.1.0 was released yesterday and worked with both IE and Firefox (and
> is still working as far as I can tell). Could you please explain your
> issue?

package org.nhweather.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.mapitz.gwt.googleMaps.client.GControl;
import com.mapitz.gwt.googleMaps.client.GLatLng;
import com.mapitz.gwt.googleMaps.client.GMap2;
import com.mapitz.gwt.googleMaps.client.GMap2Widget;
import com.mapitz.gwt.googleMaps.client.GMapOptions;

/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class Weather implements EntryPoint {

/**
* This is the entry point method.
*/
public void onModuleLoad() {
GMap2Widget mapWidget = new GMap2Widget("600", "800", new GLatLng(
37.4419, -122.1419), 13, new GMapOptions());


final GMap2 gmaps = mapWidget.getGmap();

gmaps.addControl(GControl.GMapTypeControl());
gmaps.addControl(GControl.GScaleControl());
gmaps.addControl(GControl.GLargeMapControl());
gmaps.addControl(GControl.GOverviewMapControl());

gmaps.openInfoWindowHtml(gmaps.getCenter(), "The center of the
world");

RootPanel.get("WeatherGMaps").add(mapWidget);
}
}


I had use version 2.1.0
Please visit http://www.nhweather.gd.cn/gmaps/Weather.html with
Firefox

aglaforge

unread,
Feb 2, 2007, 11:22:53 AM2/2/07
to Google Web Toolkit
Try this line instead...

GMap2Widget mapWidget = new GMap2Widget("600px", "800px", new


GLatLng(
37.4419, -122.1419), 13, new GMapOptions());

mathomas

unread,
Feb 2, 2007, 12:00:02 PM2/2/07
to Google Web Toolkit
THANK YOU!!!!!!

I was having the same exact problem - upgraded to 2.1.0 had the same
problem - switched my constructor to us "300px", "300px" instead of
"300" and my FF issue disappeared. Thank you Aglaforge!!!

Matt

aglaforge

unread,
Feb 2, 2007, 12:00:12 PM2/2/07
to Google Web Toolkit
There appears to be a problem on how GWT or Firefox handles the line:
if (height.matches("\\A\\d+\\z"))

Haven't quite nailed down the issue, but my note on the previous work
around is still correct.

> > Firefox- Hide quoted text -

aglaforge

unread,
Feb 2, 2007, 12:56:55 PM2/2/07
to Google Web Toolkit
Found the issue IE supports \A and \z and Firefox does not....

Chaning the line to fixes the issue. 2.1.1 will be released today w/
that fix and an additional startup check to ensure the V namespace is
installed in the HTML.

if (height.matches("^\\d+$"))

> > - Show quoted text -- Hide quoted text -

xkamikaze

unread,
Feb 2, 2007, 4:30:37 PM2/2/07
to Google Web Toolkit
Do you have an updated Javadocs available?

Cheers

Reply all
Reply to author
Forward
0 new messages