mikrop / v-leaflet-easyprint-parent

A leaflet plugin which adds an icon to print the map
https://vaadin.com/directory#!addon/v-leaflet-easyprint
2 stars 3 forks source link

[question] #2

Open russellhoff opened 9 years ago

russellhoff commented 9 years ago

Hi!

I've eventually finished adding the button to my map. This maps is held within several layouts: the map it's inside an horizontal layout splitting it into two parts, plus another layout.

The problem is that although the button is intended to print the map, when visualising the print preview there can be seen the whole screen.

v-leaflet-easyprint-issue

What I want to print is the map, only. Is there any way to print the map only?

mikrop commented 9 years ago

Currently the component is printing the body element. It would be possible to adjust it, once it will be ready I will share it.

russellhoff commented 9 years ago

Thanks @mikrop !!

mikrop commented 9 years ago

Added option to print only element with the map.

mikrop commented 9 years ago

@russellhoff The new version is uploaded to Vaadin repository.

russellhoff commented 9 years ago

After upgrading to the new version, an error has cropped up in this line: LEasyPrint easyPrint = new LEasyPrint();

This is the stack trace:

java.lang.NoClassDefFoundError: org/vaadin/addon/leaflet/client/LeafletControlState at com.ingartek.cavwebapp.view.administrador.verplan.ComponenteVerPlanMapa.setupMapaL(ComponenteVerPlanMapa.java:320) at com.ingartek.cavwebapp.view.administrador.verplan.ComponenteVerPlanMapa.(ComponenteVerPlanMapa.java:166) at com.ingartek.cavwebapp.view.administrador.VerPlanView.inicializarParaPlanProvisional(VerPlanView.java:124) at com.ingartek.cavwebapp.view.administrador.VerPlanView.initLayout(VerPlanView.java:95) at com.ingartek.cavwebapp.view.administrador.VerPlanView.enter(VerPlanView.java:83) at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:578) at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:527) at com.ingartek.cavwebapp.view.administrador.ComponentePlanesProvisionales.lambda$0(ComponentePlanesProvisionales.java:377) at com.ingartek.cavwebapp.view.administrador.ComponentePlanesProvisionales$$Lambda$3/9892457.click(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:508) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:198) at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161) at com.vaadin.server.AbstractClientConnector.fireEvent(AbstractClientConnector.java:977) at com.vaadin.ui.renderers.ClickableRenderer.access$300(ClickableRenderer.java:40) at com.vaadin.ui.renderers.ClickableRenderer$1.click(ClickableRenderer.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:168) at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:118) at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:291) at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:184) at com.vaadin.server.communication.PushHandler$3.run(PushHandler.java:182) at com.vaadin.server.communication.PushHandler.callWithUi(PushHandler.java:261) at com.vaadin.server.communication.PushHandler.access$200(PushHandler.java:58) at com.vaadin.server.communication.PushHandler$1.onRequest(PushHandler.java:78) at org.atmosphere.cpr.AsynchronousProcessor.action(AsynchronousProcessor.java:205) at org.atmosphere.cpr.AsynchronousProcessor.suspended(AsynchronousProcessor.java:104) at org.atmosphere.container.Servlet30CometSupport.service(Servlet30CometSupport.java:66) at org.atmosphere.cpr.AtmosphereFramework.doCometSupport(AtmosphereFramework.java:2075) at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:570) at org.atmosphere.websocket.DefaultWebSocketProcessor$3.run(DefaultWebSocketProcessor.java:332) at org.atmosphere.util.VoidExecutorService.execute(VoidExecutorService.java:101) at org.atmosphere.websocket.DefaultWebSocketProcessor.dispatch(DefaultWebSocketProcessor.java:327) at org.atmosphere.websocket.DefaultWebSocketProcessor.invokeWebSocketProtocol(DefaultWebSocketProcessor.java:424) at org.atmosphere.container.JSR356Endpoint$1.onMessage(JSR356Endpoint.java:206) at org.atmosphere.container.JSR356Endpoint$1.onMessage(JSR356Endpoint.java:203) at org.apache.tomcat.websocket.WsFrameBase.sendMessageText(WsFrameBase.java:393) at org.apache.tomcat.websocket.WsFrameBase.processDataText(WsFrameBase.java:494) at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:289) at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130) at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:60) at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:203) at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:194) at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:96) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:654) at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:285) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2431) at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2420) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.vaadin.addon.leaflet.client.LeafletControlState at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157) ... 58 more

mikrop commented 9 years ago

@russellhoff I still prefer the version to 1.1.1 once repackaged Please update to this. Note: To define an element that will be printed

LMap leafletMap = new LMap();
leafletMap.addBaseLayer(new LOpenStreetMapLayer(), "OSM");
leafletMap.setId(MAP_ID);

LEasyPrint easyPrint = new LEasyPrint();
easyPrint.setId(leafletMap.getId());
leafletMap.addControl(easyPrint); 
russellhoff commented 9 years ago

@mikrop my project crashes when I construct a LEasyPrint object instance :(

In the following line:

LEasyPrint easyPrint = new LEasyPrint();

the next stack trace:

jun 25, 2015 5:14:07 PM com.vaadin.server.DefaultErrorHandler doDefault GRAVE: java.lang.NoClassDefFoundError: org/vaadin/addon/leaflet/client/LeafletControlState at com.ingartek.cavwebapp.view.administrador.verplan.ComponenteVerPlanMapa.setupMapaL(ComponenteVerPlanMapa.java:307) at com.ingartek.cavwebapp.view.administrador.verplan.ComponenteVerPlanMapa.(ComponenteVerPlanMapa.java:157) at com.ingartek.cavwebapp.view.administrador.VerPlanView.inicializarParaPlanProvisional(VerPlanView.java:124) at com.ingartek.cavwebapp.view.administrador.VerPlanView.initLayout(VerPlanView.java:95) at com.ingartek.cavwebapp.view.administrador.VerPlanView.enter(VerPlanView.java:83) at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:578) at com.vaadin.navigator.Navigator.navigateTo(Navigator.java:527) at com.ingartek.cavwebapp.view.administrador.ComponentePlanesProvisionales.lambda$0(ComponentePlanesProvisionales.java:377) at com.ingartek.cavwebapp.view.administrador.ComponentePlanesProvisionales$$Lambda$3/23688881.click(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ...

mbasa commented 9 years ago

Hello.

I have been also trying to use EasyPrint 1.1.1 with the latest Leaflet and I also still get this exception:

com.vaadin.server.ServiceException: java.lang.NoClassDefFoundError: org/vaadin/addon/leaflet/client/LeafletControlState com.vaadin.server.VaadinService.handleExceptionDuringRequest(VaadinService.java:1463) com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1420) com.vaadin.server.VaadinServlet.service(VaadinServlet.java:350) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

For me, only version 1.0.0 works.

mikrop commented 9 years ago

Hey @russellhoff, @mbasa,

class is the artifact org.vaadin.addon.leaflet.client.LeafletControlState

        <dependency>
            <groupId>org.vaadin.addon</groupId>
            <artifactId>v-leaflet</artifactId>
            <version>0.5.7</version>
        </dependency>

what version you have registered in the dependencies? I've added a new module springboot-easyprint (https://github.com/mikrop/v-leaflet-easyprint-parent) that contains a small application where everything works.

ncabrerax commented 7 years ago

Hi @mikrop

I'm implementing the v-leaftlet-easyprint add-on with the latest version of v-leaflet (1.0.0) and vaadin 7.7.3.

When i run the command to package the project, i'm retrieving this error.

[INFO] --- vaadin-maven-plugin:7.7.3:compile (default) @ proj-widgetset ---
[INFO] auto discovered modules com.proj.presentation.AppWidgetSet]
[INFO] Compiling module com.proj.presentation.AppWidgetSet
[INFO]    Tracing compile failure path for type 'org.vaadin.addon.leaflet.easyprint.client.LeafletEasyPrintState'
[INFO]       [ERROR] Errors in 'jar:file:/Users/user/.m2/repository/org/vaadin/addons/v-leaflet-easyprint/1.1.1/v-leaflet-easyprint-1.1.1.jar!/org/vaadin/addon/leaflet/easyprint/client/LeafletEasyPrintState.java'
[INFO]          [ERROR] Line 3: The import org.vaadin.addon.leaflet.client.LeafletControlState cannot be resolved
[INFO]          [ERROR] Line 5: LeafletControlState cannot be resolved to a type
[INFO]    Tracing compile failure path for type 'org.vaadin.addon.leaflet.easyprint.client.LeafletEasyPrintConnector'
[INFO]       [ERROR] Errors in 'jar:file:/Users/user/.m2/repository/org/vaadin/addons/v-leaflet-easyprint/1.1.1/v-leaflet-easyprint-1.1.1.jar!/org/vaadin/addon/leaflet/easyprint/client/LeafletEasyPrintConnector.java'
[INFO]          [ERROR] Line 32: Cannot cast from LeafletControlState to LeafletEasyPrintState
[INFO]          [ERROR] Line 31: The return type is incompatible with AbstractControlConnector.getState()
[INFO]       [ERROR] Errors in 'jar:file:/Users/user/.m2/repository/org/vaadin/addons/v-leaflet-easyprint/1.1.1/v-leaflet-easyprint-1.1.1.jar!/org/vaadin/addon/leaflet/easyprint/client/LeafletEasyPrintState.java'
[INFO]          [ERROR] Line 3: The import org.vaadin.addon.leaflet.client.LeafletControlState cannot be resolved
[INFO]          [ERROR] Line 5: LeafletControlState cannot be resolved to a type
[INFO]    [ERROR] Aborting compile due to errors in some input files
[INFO] ------------------------------------------------------------------------

I want to print only the map passing the map id element, but i can't package to deploy the project.

How, i can use this feature?

mikrop commented 7 years ago

Hi @ncabrerax

The latest release is https://vaadin.com/directory#!addon/v-leaflet-easyprint This version is stored in the repository:

<dependency>
   <groupId>org.vaadin.addons</groupId>
   <artifactId>v-leaflet-easyprint</artifactId>
   <version>1.1.1</version>
</dependency>

<repository>
   <id>vaadin-addons</id>
   <url>http://maven.vaadin.com/vaadin-addons</url>
</repository>

The latest version of leaflet-easyprint-parent-1.1.2-SNAPSHOT contains submodule springboot-easyprint as a sample application