Mapitz GWT CustomMap: Totally lost

10 views
Skip to first unread message

loewen...@googlemail.com

unread,
Jul 18, 2007, 7:38:21 AM7/18/07
to Google Web Toolkit
Hi There,

for the last couple of hours, I try to get a custom map layer running
on the Google Maps Package by Mapitz. I couldn't find any example
Projects or complete tutorials to help me get started with this. I'm
relatively new to GWT and especially the Syntax regarding JSNI totally
confuses me. I have pictures of a region in better resolution than
Google has and would like to put them on top of my application, I
successfully sliced them into tiles including the coordinates and zoom
levels.

The Class that I want to handle my custom layer is not compiling at
all as soon as I implement those JSNI methods. Have to admit that I
don't understand what this syntax is about..

Any help is highly appreciated or just even a link to some tutorial or
example project would be great.

The errors the compiler is throwing:
Error acquiring source for com.myPackage.client.map.client.map.Overlay

The class:

package com.myPackage.client.map;

import com.mapitz.gwt.googleMaps.client.*;

public class Overlay {

public Overlay() {

GCopyright copyright = new GCopyright(1, new GLatLngBounds(new
GLatLng(-90, -180), new GLatLng(90, 180)),0,"©2006 Something.com");
GCopyrightCollection ccollection = new GCopyrightCollection("this is
my nice copyright");
ccollection.addCopyright(copyright);

GTileLayer tilelayer = new GTileLayer(ccollection, 16, 16);

initLayer(tilelayer.getJSObject(), this);
}

public String getTileUrl(int x, int y, int zoom)
{
int z = zoom;
String f = "/maps/?x="+x+"&y="+y+"&zoom="+z;
return f;
}

public String getOpacity(){ return "adas";};

private native void initLayer(JSObject layer, Overlay tileUrlHandler)
/*-{
layer.getTileUrl = function(t,z)
{
return m...@com.myPackage.map.Overlay::getTileUrl(III)
(t.x, t.y, z);
};

layer.isPng = function()
{
return true;
};

layer.getOpacity = function()
{
return m...@com.myPackage.map.Overlay::getOpacity()();
};

}-*/;

}

Miguel Méndez

unread,
Jul 19, 2007, 8:43:19 AM7/19/07
to Google-We...@googlegroups.com
FYI, we are working on a version of the Maps API which will be part of the gwt-google-apis project.  This is one of the use cases that we are considering.  I would expect the discussion on this version of the Maps API to start rolling within the next week or so; once the next 1.4 RC takes shape.

Stay tuned.

Cheers,


Hi There,

for the last couple of hours, I try to get a custom map layer running
on the Google Maps Package by Mapitz. I couldn't find any example
Projects or complete tutorials to help me get started with this. I'm
relatively new to GWT and especially the Syntax regarding JSNI totally
confuses me. I have pictures of a region in better resolution than
Google has and would like to put them on top of my application, I
successfully sliced them into tiles including the coordinates and zoom
levels.

The Class that I want to handle my custom layer is not compiling at
all as soon as I implement those JSNI methods. Have to admit that I
don't understand what this syntax is about..

Any help is highly appreciated or just even a link to some tutorial or
example project would be great.

The errors the compiler is throwing:
Error acquiring source for com.myPackage.client.map.client.map.Overlay

The class:

package com.myPackage.client.map;

import com.mapitz.gwt.googleMaps.client.*;

public class Overlay  {

        public Overlay() {

                GCopyright copyright = new GCopyright(1, new GLatLngBounds(new
GLatLng(-90, -180), new GLatLng(90, 180)),0,"(c)2006 Something.com");

krispy

unread,
Jul 19, 2007, 9:53:25 AM7/19/07
to Google Web Toolkit
No JSNI needed - Aglaforge has made this extremely simple (it used to
involve JSNI but he modified the wrapper as per my request):

1) extend the GAbstractTileLayer class with your own.
2) implement the getOpacity(), isPng(), and getTileUrl() functions
3) make the copyright like you do above and add it to your custom tile
layer
4) add the custom tile layer to a new GMapType OR add the custom layer
to a new GTileLayerOverlay (the difference is that the GMapType will
create a button next to the "Satellite" and "Hybrid" buttons which
will only show your tiles when clicked, but the GTileLayerOverlay will
just make an overlay on top of the existing GMapType tiles).

Feel free to ask any more questions - HTH!

-krispy

On Jul 18, 7:38 am, "loewenspr...@gmail.com"

krispy

unread,
Jul 19, 2007, 10:00:43 AM7/19/07
to Google Web Toolkit
Miguel,

Is this going to be created using the JSNI wrapper stuff that Bob V.
has been doing on the Contributors forum? If so, it ought to be very
interesting - it's one of those things that I've been waiting in
anticipation for. The ability to wrap any Javascript library without
any JSNI needed would be an incredible addition to GWT - I've also
thought before that this could work in conjunction with Ray Cromwell's
Exporter to produce "instant" GWT APIs that 3rd party developers could
create plug-in applications with. Anyways, I'm excited to see what's
coming up next - keep up the great work!

-krispy

On Jul 19, 8:43 am, "Miguel Méndez" <mmen...@google.com> wrote:
> FYI, we are working on a version of the Maps API which will be part of the

> gwt-google-apis <http://code.google.com/p/gwt-google-apis/> project. This


> is one of the use cases that we are considering. I would expect the
> discussion on this version of the Maps API to start rolling within the next
> week or so; once the next 1.4 RC takes shape.
>
> Stay tuned.
>
> Cheers,
>

> --
> Miguel

Miguel Méndez

unread,
Jul 19, 2007, 10:24:14 AM7/19/07
to Google-We...@googlegroups.com
There is still a debate as to whether this capability should be a first class concept in GWT, or whether a rebind based solution is the way to go.  So, we are planning to leverage BobV's work to generate the implementation details.  We want to use these libraries to explore the problem but we want to make sure that the users of the libraries will not be impacted if we find that we need to change our approach.

I'm still not convinced that it is possible to *always* automatically create a Java API that adheres to Java API design best practices solely based on an existing JavaScript one.  However, I do see that it is valuable to able to quickly get access to a JavaScript API to get stuff done.  We'll have to wait and see what we learn to know for sure.

loewen...@googlemail.com

unread,
Jul 20, 2007, 4:48:57 AM7/20/07
to Google Web Toolkit
Hi Krispy,

thanks again for your kind help. I followed the steps you recommended
and I am some steps further now. Now the compiler and some
InternetExplorer popup (think it belongs to hosted browser) are
throwing the following errors:

The popup:

Stack overflow at line: 0

and the compiler:

[ERROR] Unable to load module entry point class
es.vicomtech.floelhoeffel.client.GMapsGWT (see associated exception
for details)
com.google.gwt.core.client.JavaScriptException: JavaScript Error
exception: Espacio de pila insuficiente
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
481)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:
270)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:
137)
at
com.mapitz.gwt.googleMaps.client.GMap2Impl.addOverlay(GMap2Impl.java:
244)
at com.mapitz.gwt.googleMaps.client.GMap2.addOverlay(GMap2.java:358)
at es.vicomtech.floelhoeffel.client.map.MapView.<init>(MapView.java:
56)
at
es.vicomtech.floelhoeffel.client.ApplicationController.<init>(ApplicationController.java:
29)
at
es.vicomtech.floelhoeffel.client.ApplicationController.getInstance(ApplicationController.java:
64)
at
es.vicomtech.floelhoeffel.client.GMapsGWT.onModuleLoad(GMapsGWT.java:
20)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:342)


I extended GAbstractTileLayer like this:


public class Overlay extends GAbstractTileLayer {

public Overlay(GCopyrightCollection copyrights, int minResolution,
int maxResolution) {

super( copyrights, minResolution,maxResolution);

}

public String getTileUrl(int x, int y, int zoom)
{
int z = zoom;

String f = "/images/map-tiles/"+x+"_"+y+"_"+z+".gif";
return f;
//return "http://kh3.google.com/kh?n=404&v=14&t=t";

}

public double getOpacity(){

return 0;

};

public boolean isPng() {

return false;

}

}


Any ideas what this could cause?

Thanks a lot in advance!

Frederik

krispy

unread,
Jul 20, 2007, 10:16:56 AM7/20/07
to Google Web Toolkit
Well, I'm guessing that "Espacio de pila insuficiente" means
"insufficient stack space" - did you try with the JVM argument "-
Xmx512m" (just sets the max memory for the JVM to 512 MB)? Just a
shot in the dark - otherwise, I'd have to see more of your code to
understand what's going on ... another guess: are the images you're
returning for tiles too big? They should only be 256x256 - and
lastly, are you sending valid GIF images? Maybe it's going crazy b/c
your tiles aren't formatted correctly? Just some things to think
about -

-krispy

On Jul 20, 4:48 am, "loewenspr...@gmail.com"

loewen...@googlemail.com

unread,
Jul 26, 2007, 3:58:11 AM7/26/07
to Google Web Toolkit
Hi Krispy,

thanks a lot for your help again and sorry for the spanish version of
"Stack overflow" :) The problem was, that I was missing some arguments
in getTileURL(). I used

public String getTileUrl(int x, int y, int zoom)

instead of

public String getTileUrl(GPoint point, int zoom)

Eclipse compiled fine but when testing, JavaScript crashed because of
the wrong arguments. So finally I got my custom map overlay working!
To pay back to the community I upped an example project on my webspace
that includes some custom tiles and the custom overlay.

Its available at:

http://www.loewensprung.de/tutorials/gwt-custom-map-overlay#comment

Regards

Frederik

> > > 4) add the custom tile layer to a newGMapTypeOR add the custom layer

Reply all
Reply to author
Forward
0 new messages