Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/434.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java GWT谷歌地图V3覆盖窗口小部件_Java_Javascript_Google Maps_Gwt_Google Maps Api 3 - Fatal编程技术网

Java GWT谷歌地图V3覆盖窗口小部件

Java GWT谷歌地图V3覆盖窗口小部件,java,javascript,google-maps,gwt,google-maps-api-3,Java,Javascript,Google Maps,Gwt,Google Maps Api 3,我正在使用GWT google maps V3 API,我需要在地图上显示自定义形状。 对于简单的元素,我使用了Polygon、Circle和InfoWidnow类,但我想显示一些其他小部件,比如按钮或自定义面板。 使用OverlayView类有什么方法可以做到这一点吗?我尝试了一个简单的解决方案:一个包含MapWidget和我的自定义Widget的AbsolutePanel,放在上面,但我希望尽可能多地使用gwt google maps类。我已经阅读了文档,也搜索了答案,但我想不出答案,所以一

我正在使用GWT google maps V3 API,我需要在地图上显示自定义形状。 对于简单的元素,我使用了Polygon、Circle和InfoWidnow类,但我想显示一些其他小部件,比如按钮或自定义面板。 使用OverlayView类有什么方法可以做到这一点吗?我尝试了一个简单的解决方案:一个包含MapWidget和我的自定义Widget的AbsolutePanel,放在上面,但我希望尽可能多地使用gwt google maps类。我已经阅读了文档,也搜索了答案,但我想不出答案,所以一个代码示例就很好了。
塔克斯

只需将标准GWT API与您的maps V3 API一起使用即可。它们可以很好地互连。

我在这里找到了我需要的东西(javascript v3 api):

方法名称和类非常相似,因此不难弄清楚GWT类应该如何使用(如OverlayView)

下面是一个在地图上呈现自定义小部件(包含SVG元素和动画)的示例:

private class TargettingOverlay extends OverlayView {

    protected Element div ;
    protected PanelWrapper panelWrapper;
    private TargettingEffect targetEffect;

    TargettingOverlay(){
        targetEffect = new TargettingEffect();
        targetEffect.setLinedDimension(10500);
        targetEffect.setLinesOffset(-5000);
    }

    void positionTarget(LatLng loc, boolean withoutLines){
        if (targetEffect == null )
            return;

        if (loc == null) {
            targetEffect.setElementsVisible(false);
            return;
        }
        targetEffect.setElementsVisible(true);


        Point p = null;
        Point sw = null;
        Point ne = null;
        LatLng locSW = (LatLng)this.getMap().getBounds().getSouthWest();
        LatLng locNE = (LatLng)this.getMap().getBounds().getNorthEast();

        //
        p = (Point)getProjection().fromLatLngToDivPixel(loc);
        sw = (Point)getProjection().fromLatLngToDivPixel(locSW);
        ne = (Point)getProjection().fromLatLngToDivPixel(locNE);



        targetEffect.setWithoutLinles(withoutLines);
        targetEffect.target((int)ne.getY(), (int)p.getY(), (int)sw.getX(), (int)p.getX());
    }

    @Override
    public void draw() {
        Point ne = (Point)getProjection().fromLatLngToDivPixel((LatLng)
                this.getMap().getBounds().getNorthEast());
        Point sw = (Point)getProjection().fromLatLngToDivPixel((LatLng)
                this.getMap().getBounds().getSouthWest());


        div.getStyle().setTop(ne.getY(), Unit.PX);
        div.getStyle().setLeft(sw.getX(), Unit.PX); 
    }

    @Override
    public void onAdd() {
        div = DOM.createDiv();

        getPanes().getOverlayLayer().appendChild(div);

        panelWrapper = new PanelWrapper(div);
        panelWrapper.attach();          

        targetEffect.setContainer(panelWrapper);
    }

    @Override
    public void onRemove() {
        div.removeFromParent();
        panelWrapper.removeFromParent();

        div = null;
        panelWrapper = null;
    }

}

我已经尝试过了(使用gwt的小部件),但我想使用gwt google maps api中尽可能多的类(我觉得更多的是覆盖视图类)。如果你能在某个地方提供一个示例或链接,那就太好了。只要在eclipse中链接两个JAR并从两个JAR中使用,我的意思不是,我指的是一个使用OverlayView在地图上添加自定义小部件的代码示例,如果可能的话