abarros9321 / gwt-maps-api

Automatically exported from code.google.com/p/gwt-maps-api
0 stars 0 forks source link

Custom overlay class not correct implemented... #2

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. As we see in the implementation for the CustomOverlay object in the js 
specification this class needs to be, so to say, extended and than the api 
calls its on methods onAdd, onRemove and draw which we extend and we can make 
coresponding actions.
2.  If we use the CustomOverlay class from the gwt wraper, the class it self is 
abstract what is ok, but the 3 methods are final(must be final, because this 
class extends JavaScriptObject class) so there is no way we can extend this 
class and create our custom overlay..
3. In the previus GWT API 2 this class was not extendind JSO and the callback 
methods wore annotetad with @Export, I didnt had time to go inside the 
implementation but I also check in the 
http://code.google.com/p/gwt-google-maps-v3/ and the implement of the Overlay 
abstract class looks similar as the one in V2 api. 

I tryed by wraping this class and setting the 3 methods on a native calls which 
make a reverse call to java methods, the native methods work but this 
coresponding java methods are never called..
Example:

public class MyTextOverlay {

    private final LatLng latLng;

    private final SimplePanel textPanel;

    private String text;

    private Point offset;

    private OverlayView overlay = OverlayView.newInstance();

    /**
     * Main constructor
     * @param latLng
     */
    public MyTextOverlay(LatLng latLng, String text, Point offset) {
        /* Save our inputs to the object */
        String[] st = text.split(" ");
        text = "";
        for (String s : st)
            text+=s;

        this.latLng = latLng;
        this.text = text;
        this.offset = offset;

        /* Create a widget for the text */
        ....

        // must be call to init the callbacks
        initOverlay( overlay);

    }

    private final native void initOverlay( JavaScriptObject jso) /*-{
        var instance = this;
        jso.draw = function() {

            instance.@mk.icelabs.vtcustomer.client.view.components.map.MyTextOverlay::myDraw();
        };

        jso.onAdd = function() {
    instance.@mk.icelabs.vtcustomer.client.view.components.map.MyTextOverlay::myOnAdd();
        };

        jso.onRemove = function() {
            instance.@mk.icelabs.vtcustomer.client.view.components.map.MyTextOverlay::myOnRemove();
        };
    }-*/;

... the methods here...

Any idea?!

I really like your library you have done a very good job, it still  has some 
small problems but I fix some of dose on the fly:)

Blaze

Original issue reported on code.google.com by baze...@gmail.com on 2 Mar 2012 at 10:25

GoogleCodeExporter commented 9 years ago
hey thanks alot i was looking away to do this. to make ur code work

$entry(instance.@com.shared.lib.com.map.CustomOverlayView::myDraw()());

seems to be the way to assign function

Original comment by jien...@gmail.com on 10 Oct 2012 at 7:18