简体   繁体   English

无法解析类中的方法

[英]unable to resolve method in class

1.is it possible to call the native method in the gwt into the other native method ? 1.是否可以将gwt中的本机方法调用到其他本机方法中?

this is the method i am calling from the VectorSource.java into Map.java https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/client/source/VectorSource.java 这是我从VectorSource.java调用到Map.java的方法https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/客户端/源/VectorSource.java

 public final native JsArray<Feature> getFeatures()/*-{
        return this.getFeatures();
    }-*/;

and i created a native method in Map.java class and getting the Features and i want to return these feature values to addOnPostRenderListener method below are the changes in the Map.java class 我在Map.java类中创建了一个本机方法并获取功能,我想将这些功能值返回给addOnPostRenderListener方法,以下是Map.java类中的更改

    public native final Feature getFeatures(VectorSource sourceFeature)/*-{
    var features=sourceFeature.@org.vaadin.gwtol3.client.source.VectorSource::getFeatures();
    return features;
    }-*/;


    public native final void addOnPostRenderListener(OnPostRenderListener listener)/*-{


       if(!this.__registered){
       var that=this;

       that.once('postrender',function(){
        var feature=that.@org.vaadin.gwtol3.client.Map::getFeatures(vectorSource);
        if(feature!=null){
        var coordinate=feature.getGeometry().getCoordinate();
        if(coordinates!=null){
        var MapEvent={Pixel:that.getPixelFromCoordinate(that.__transformInputCoordinate(coordinates))};
        that.__notifyPostRenderListeners(MapEvent);
        }
        }})
        this.__postRenderListeners.push(listener);
        }
    }-*/;

the remaining code remains the same as shown in the below link https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/client/Map.java 其余代码与以下链接https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/client/Map中显示的相同。爪哇

at the below code i am getting the error,as Expected a valid parameter type signature in JSNI method reference these lines of code is in the addOnPostRenderListener method 在下面的代码中,我遇到了错误,因为在JSNI方法参考中期望有效的参数类型签名,这些代码行在addOnPostRenderListener方法中

 var feature=that.@org.vaadin.gwtol3.client.Map::getFeatures(vectorSource);

my target is to call the method getFeatures() from VectorSource.java class into the Map.java class and send the values to the other native method which is addOnPostRenderListener method. 我的目标是将VectorSource.java类中的getFeatures()方法调用到Map.java类中,并将值发送给另一个本机方法,即addOnPostRenderListener方法。

Interface 接口

public interface OnPostRenderListener {

    public void onRender(MapEvent posEvent);
}

MapEvent MapEvent

public class MapEvent extends JavaScriptObject {


    protected MapEvent() {

    }


     public static final native Feature create()/*-{
     return new $wnd.ol.Feature();
      }-*/;


     public native final Geometry getGeometry()-{
        return this.getGeometry();
       }-;*/


    public native final Geometry getGeometry()/*-{
        return this.geometry;
    }-*/;

    public native final Coordinate getCoordinate()/*-{
    return this.coordinate;
     }-*/;


   public native final Pixel getPixel()/*-{
    return this.Pixel;
    }-*/;

   //written code not used 
   public native final Map getPixelFromCoordinate(Coordinate coord)/*-{
     return this.getPixelFromCoordinate(coord);
    }-*/;
}

You need to pass your VectorSource sourceFeature parameter too. 您还需要传递VectorSource sourceFeature参数。 You are missing it in that.@org.vaadin.gwtol3.client.Map::getFeatures(Lcom/google/gwt/core/client/Source;); 您在that.@org.vaadin.gwtol3.client.Map::getFeatures(Lcom/google/gwt/core/client/Source;);中丢失了它that.@org.vaadin.gwtol3.client.Map::getFeatures(Lcom/google/gwt/core/client/Source;); .

One way to do this, would be add it to your 一种方法是将其添加到您的

addOnPostRenderListener(OnPostRenderListener listener)

eg addOnPostRenderListener(OnPostRenderListener listener, VectorSource vectorSource) 例如addOnPostRenderListener(OnPostRenderListener listener, VectorSource vectorSource)

and then to access it like this: 然后像这样访问它:

var feature=that.@org.vaadin.gwtol3.client.Map::getFeatures(vectorSource);

Although I would recommend to completely drop JSNI and use the much better JsInterop . 尽管我建议完全删除JSNI并使用更好的JsInterop There is an OL-implementation using JsInterop too. 也有一个使用JsInterop的OL实现。 Take a look here 在这里看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM