0

there is a method in the OLMap class of v-ol3(vaadin-Openlayers4) as :

map.addClickListener(new OLMap.ClickListener() {

@Override
public void onClick(OLClickEvent clickEvent) {

//calling  some method to execute when we click on the map  
 } 
});

when ever we click on the map

new OLmap.ClickListener()

will act and will call the method written inside the onClick() method ,but i want without click on the map which means when the map is rendered there should be some listener that will call the method inside some event. As per the API what i understood is they implemented for the ClickListener on the map , now i want to extend an API for a Listener that will be called when the map is rendered

is there any such kind of Listener in java that will be called immediately after the application is launched ?

actually i want to get the Pixel values of the Point which i am able to get in javascript as shown below ,

map.once('postrender', function() {
 var geometry = polyFeature.getGeometry();
var coordinate = geometry.getCoordinates();
var pixel1 = map.getPixelFromCoordinate(coordinate);
});
map.setView(view)

but i want to implement in java using v-ol3 jar , but there is only implementation for the click listener on the map and not for the map rendered listener , so what kind of Listener do i need to implement for that or is there any kind of Listener in java ?

Importanat:v-ol3 depends on the gwt-ol3(GWT_Opelayers) . in the gwt-ol3 the ol.js(openlayers is wrapped )

RamanaMuttana
  • 481
  • 6
  • 22

1 Answers1

1

When the functionality is not in the API, the reason is there maybe is not code for it yet. So is the case now.

See:

https://github.com/VOL3/v-ol3/blob/master/gwt-ol3/src/main/java/org/vaadin/gwtol3/client/Map.java

has a snippet:

//    public native final void beforeRender()/*-{
//        //TODO: find a nice way to do this in GWT
//    }-*/;

So this is the only event related to Map rendering and loading on ol3-v gwt wrapper (there is also a vaadin wrapper on top of it).

You can search the Internet about Map loaded, there is no way to catch such easily.

OpenLayers: How to detect the map view is completely loaded?

tells how to do it, it needs watching for start and ready events per layer on Map. Then after those done (you calculate nothing is to be loaded anymore), you wrap code inside the gwt wrapper and finally to vaadin wrapper and you have an event to register.

mico
  • 12,730
  • 12
  • 59
  • 99