From 30ab1b9185619f5095ba3e6124fb6d585f1355f9 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 2 Sep 2021 18:15:15 +0200 Subject: [PATCH] added download layer --- .../client/GeoportalDataViewerConstants.java | 22 +++- .../client/OLMapManager.java | 8 -- .../client/gis/LightOpenLayerOSM.java | 91 ++++++++++++++- .../client/gis/OpenLayerOSM.java | 58 +++++----- .../client/ui/map/MapView.java | 109 +++++++++--------- .../products/concessioni/ConcessioneView.java | 8 +- .../concessioni/LayerConcessioneView.java | 76 +++++++++++- 7 files changed, 268 insertions(+), 104 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java index 6792d3b..a19011f 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewerConstants.java @@ -14,9 +14,6 @@ import com.google.gwt.i18n.client.DateTimeFormat; */ public class GeoportalDataViewerConstants { -// public static final String EPSG_4326 = "EPSG:4326"; -// public static final String EPSG_3857 = "EPSG:3857"; - public static final String MAP_DIV = "map"; public static final String GET_WMS_PARAMETER = "wmsrequest"; @@ -81,5 +78,24 @@ public class GeoportalDataViewerConstants { public static native void printJs(String msg)/*-{ console.log("js console: " + msg); }-*/; + + /** + * Prints the. + * + * @param msg the msg + */ + public static native void printJsObj(Object object)/*-{ + console.log("js obj: "+JSON.stringify(object, null, 4)); + }-*/; + + + /** + * Prints the. + * + * @param msg the msg + */ + public static native String toJsonObj(Object object)/*-{ + return JSON.stringify(object); + }-*/; } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java index d479963..216f6ab 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/OLMapManager.java @@ -126,14 +126,6 @@ public class OLMapManager { }; - // EPSG_4326_TO_ITALY -// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, -// GeoportalDataViewerConstants.ITALY_CENTER_LAT); -// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, -// MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); -// olMap.setCenter(transformedCenterCoordinate); -// olMap.setZoom(GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON); - Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); olMap.setCenter(transformedCenterCoordinate); diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java index cb44a29..025120a 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/LightOpenLayerOSM.java @@ -1,6 +1,11 @@ package org.gcube.portlets.user.geoportaldataviewer.client.gis; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; +import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; @@ -8,7 +13,12 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; +import com.google.gwt.json.client.JSONObject; +import com.google.gwt.json.client.JSONParser; +import com.google.gwt.json.client.JSONString; +import com.google.gwt.json.client.JSONValue; +import ol.Collection; import ol.Coordinate; import ol.Feature; import ol.Map; @@ -22,6 +32,7 @@ import ol.event.EventListener; import ol.geom.Point; import ol.interaction.KeyboardPan; import ol.interaction.KeyboardZoom; +import ol.layer.Base; import ol.layer.Image; import ol.layer.LayerOptions; import ol.layer.Tile; @@ -32,6 +43,7 @@ import ol.source.ImageWms; import ol.source.ImageWmsOptions; import ol.source.ImageWmsParams; import ol.source.Osm; +import ol.source.Source; import ol.source.XyzOptions; import ol.style.Icon; import ol.style.IconOptions; @@ -172,7 +184,7 @@ public class LightOpenLayerOSM { * * @param mapServerHost the map server host * @param layerName the layer name - * @param bbox + * @param bbox the bbox * @return the image */ public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) { @@ -214,6 +226,83 @@ public class LightOpenLayerOSM { return null; } + /** + * Gets the layers. + * + * @return the layers + */ + public List getLayers() { + Collection layers = map.getLayers(); + List layerNames = null; + if (layers != null) { + Base[] layersArr = layers.getArray(); + layerNames = new ArrayList(layersArr.length); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + if (layer instanceof Image) { + Image layerImage = (Image) layer; + + Source source = layerImage.getSource(); +// GWT.log("source: "+source.toString()); + GeoportalDataViewerConstants.printJsObj(source); + String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); + JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); + // GWT.log("jsonObj: " + jsonObj.toString()); + JSONObject jsonSourceObj = (JSONObject) jsonObj; + + JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_"); + // GWT.log("jsonParamsObj is: "+jsonParamsObj); + JSONValue jsonLayers = jsonParamsObj.get("LAYERS"); + GWT.log("theLayerName name is: " + jsonLayers); + layerNames.add(jsonLayers.toString()); + } + } + } + return layerNames; + } + + public java.util.Map getLayerURLsProperty() { + + Collection layers = map.getLayers(); + java.util.Map mapLayerNameURL = new HashMap(); + if (layers != null) { + Base[] layersArr = layers.getArray(); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + // GeoportalDataViewerConstants.printJsObj(layer); + if (layer instanceof Image) { + Image layerImage = (Image) layer; + + Source source = layerImage.getSource(); +// GWT.log("source: "+source.toString()); +// GeoportalDataViewerConstants.printJsObj(source); + String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source); + JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj); +// GWT.log("jsonObj: " + jsonObj.toString()); + JSONObject jsonSourceObj = (JSONObject) jsonObj; + + JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_"); + // GWT.log("jsonParamsObj is: "+jsonParamsObj); + JSONString jsonLayers = (JSONString) jsonParamsObj.get("LAYERS"); + String layerName = jsonLayers.stringValue(); + GWT.log("jsonLayers is: " + layerName); +// GWT.log("theLayerName name is: " + jsonLayers); + + JSONValue jsonImage = jsonSourceObj.get("image_"); +// GWT.log("jsonImage: " + jsonImage.toString()); + JSONObject jsonImageObj = (JSONObject) jsonImage; + JSONString jsonSrc = (JSONString) jsonImageObj.get("src_"); + String layerURL = jsonSrc.stringValue(); + GWT.log("jsonSrc: " + layerURL); + mapLayerNameURL.put(layerName, layerURL); + } + + } + } + GWT.log("returning mapLayerNameURL: "+mapLayerNameURL); + return mapLayerNameURL; + } + /** * Adds the point. * diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java index c400859..3bb4bd3 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/gis/OpenLayerOSM.java @@ -403,8 +403,12 @@ public abstract class OpenLayerOSM { } + /** + * Removes the all detail layers. + */ public void removeAllDetailLayers() { + //NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION /* if (wmsDetailsLayerMap == null) @@ -422,32 +426,6 @@ public abstract class OpenLayerOSM { } -// public void addGeometry(Geometry theGeom) { -// -// if(theGeom==null) -// return; -// -// if(geometryLayer==null) { -// geometryLayer = new Vector("Feature selected"); -// geometryLayer.setDisplayInLayerSwitcher(false); -// map.addLayer(geometryLayer); -// }else { -// geometryLayer.removeAllFeatures(); -// } -// Style style = new Style(); -// style.setFillColor("#00FF00"); -// style.setGraphicName("circle"); -// style.setPointRadius(10); -// VectorFeature vf = new VectorFeature(theGeom, style); -// geometryLayer.addFeature(vf); -// } -// -// -// protected void removeGeometries() { -// if(geometryLayer!=null) -// geometryLayer.removeAllFeatures(); -// } - /** * Adds the vector. * @@ -588,7 +566,7 @@ public abstract class OpenLayerOSM { for (int i = 0; i < layersArr.length; i++) { Base layer = layersArr[i]; String theLayerName = (String) layer.get("name"); - GWT.log("The Layer name is: " + layerName); + GWT.log("The Layer name is: " + theLayerName); if (theLayerName != null && theLayerName.equals(layerName)) return true; } @@ -596,6 +574,32 @@ public abstract class OpenLayerOSM { return false; } + + + /** + * Gets the layer property. + * + * @param layerName the layer name + * @param property the property + * @return the layer property + */ + public String getLayerProperty(String layerName, String property) { + + Collection layers = map.getLayers(); + + if (layers != null) { + Base[] layersArr = layers.getArray(); + for (int i = 0; i < layersArr.length; i++) { + Base layer = layersArr[i]; + String theLayerName = (String) layer.get("name"); + GWT.log("The Layer name is: " + layerName); + if (theLayerName != null && theLayerName.equals(layerName)) + return layer.get(property); + } + } + + return null; + } /** * Gets the projection code. diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java index 829b4f7..6761490 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/map/MapView.java @@ -23,14 +23,14 @@ import com.google.gwt.user.client.ui.Widget; import ol.Coordinate; import ol.OLFactory; - /** - * The Class MapView. - * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * - * Nov 11, 2020 - */ - public class MapView extends Composite{ +/** + * The Class MapView. + * + * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) + * + * Nov 11, 2020 + */ +public class MapView extends Composite { private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class); @@ -39,55 +39,47 @@ import ol.OLFactory; * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * - * Nov 11, 2020 + * Nov 11, 2020 */ interface MapViewUiBinder extends UiBinder { } - + @UiField HTMLPanel theMap; - + @UiField HorizontalPanel coordinatePanel; - - private LightOpenLayerOSM olsm; - + + private LightOpenLayerOSM lightOLSM; + /** * Instantiates a new map view. * * @param centerTo the center to - * @param zoom the zoom + * @param zoom the zoom */ public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) { initWidget(uiBinder.createAndBindUi(this)); - String theMapId = "map"+Random.nextInt(); + String theMapId = "map" + Random.nextInt(); theMap.getElement().setId(theMapId); theMap.setWidth(internalMapWidth); theMap.setHeight(internalMapHeight); - + Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { - olsm = new LightOpenLayerOSM(theMapId); - - //EPSG_3857 LOCATION TO ITALY + lightOLSM = new LightOpenLayerOSM(theMapId); + + // EPSG_3857 LOCATION TO ITALY Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); - olsm.setCenter(transformedCenterCoordinate); - olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); - -// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); -// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857); -// olsm.setCenter(transformedCenterCoordinate); -// olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); - - //setMapSize(); - + lightOLSM.setCenter(transformedCenterCoordinate); + lightOLSM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON); } }); } - + private void setMapSize() { Scheduler.get().scheduleDeferred(new ScheduledCommand() { @@ -95,38 +87,38 @@ import ol.OLFactory; public void execute() { int width = theMap.getParent().getOffsetWidth(); int height = theMap.getParent().getOffsetHeight(); - if(width==0) + if (width == 0) width = 300; - - if(height==0) + + if (height == 0) height = 300; - - GWT.log("Internal Map w: "+width + ", h: "+height); - theMap.setSize(width+"px", height+"px"); + + GWT.log("Internal Map w: " + width + ", h: " + height); + theMap.setSize(width + "px", height + "px"); } }); } - + /** * Adds the marker. * - * @param coordinate the coordinate + * @param coordinate the coordinate * @param showCoordinateText the show coordinate text */ - public void addMarker(Coordinate coordinate, boolean showCoordinateText) { - + public void addMarker(Coordinate coordinate, boolean showCoordinateText) { + Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { - if(olsm!=null) { - olsm.addPoint(coordinate, showCoordinateText, true); - olsm.getMap().getView().setCenter(coordinate); + if (lightOLSM != null) { + lightOLSM.addPoint(coordinate, showCoordinateText, true); + lightOLSM.getMap().getView().setCenter(coordinate); } } }); } - + /** * Adds the WMS layer. * @@ -139,12 +131,12 @@ import ol.OLFactory; @Override public void execute() { - + ExtentWrapped ew = null; BoundsMap theBBOX = bbox; - + if (bbox != null) { - + Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY()); Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); @@ -152,22 +144,27 @@ import ol.OLFactory; Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY()); Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName()); - + ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY()); - theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null); + theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), + null); } - - olsm.addWMSLayer(mapServerHost, layerName, theBBOX); + + lightOLSM.addWMSLayer(mapServerHost, layerName, theBBOX); if (ew != null) { - - olsm.getMap().getView().fit(ew); + + lightOLSM.getMap().getView().fit(ew); } } }); - + } - + + public LightOpenLayerOSM getLightOLSM() { + return lightOLSM; + } + } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java index 959e434..1423f69 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/ConcessioneView.java @@ -266,16 +266,16 @@ public class ConcessioneView extends Composite { if(listLayersDV==null) return; - for (LayerConcessioneDV layer : listLayersDV) { + for (LayerConcessioneDV layerDV : listLayersDV) { - if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) { + if(layerDV.getPolicy()==null || layerDV.getPolicy().equalsIgnoreCase("OPEN")) { piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layer)); + piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); }else { //I need to be authenticated to show the fields according to POLICY if(myLogin!=null) { piantaFineScavoPanel.setVisible(true); - piantaFineScavoPanel.add(new LayerConcessioneView(layer)); + piantaFineScavoPanel.add(new LayerConcessioneView(layerDV)); } } } diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java index 0b1e57a..d194695 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/ui/products/concessioni/LayerConcessioneView.java @@ -1,5 +1,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni; +import java.util.Map; + import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION; @@ -8,11 +10,15 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.L import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE; import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView; import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable; -import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil; +import com.github.gwtbootstrap.client.ui.DropdownButton; +import com.github.gwtbootstrap.client.ui.NavLink; import com.google.gwt.core.client.GWT; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.Window; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; @@ -49,10 +55,6 @@ public class LayerConcessioneView extends Composite { GWT.log("WMS LINK: " + layerDV.getWmsLink()); if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) { - String pngWMSLink = URLUtil.setValueOfParameter("FORMAT", layerDV.getWmsLink(), "image/png", true); - - customTable.addNextKeyWidget("Layer", new HTML("download image")); - Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY); Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857); // Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT); @@ -64,8 +66,72 @@ public class LayerConcessioneView extends Composite { String mapServerHost = layerDV.getWmsLink().contains("?") ? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?")) : layerDV.getWmsLink(); + + DropdownButton downloadButt = new DropdownButton("download as..."); + NavLink navLink = new NavLink("PNG"); + HTML html = new HTML(""); + navLink.getElement().appendChild(html.getElement()); + navLink.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + Map mapLayerURLs = mapView.getLightOLSM().getLayerURLsProperty(); + + String layerURL = mapLayerURLs.get(layerDV.getLayerName()); + GWT.log("layerDV name is: " + layerDV.getLayerName()); + if (layerURL != null) + Window.open(layerURL, "_blank", null); + + //downloadMap(mapView.getLightOLSM().getMap()); + } + }); + + downloadButt.add(navLink); + customTable.addNextKeyWidget("Layer", downloadButt); mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox()); } } + /** + * Prints the. + * + * @param msg the msg + */ + public static native void downloadMap(ol.Map map)/*-{ + console.log("map: " + map); + map.once('rendercomplete', function() { + var mapCanvas = document.createElement('canvas'); + var size = map.getSize(); + mapCanvas.width = size[0]; + mapCanvas.height = size[1]; + var mapContext = mapCanvas.getContext('2d'); + Array.prototype.forEach.call(document + .querySelectorAll('.ol-layer canvas'), function(canvas) { + if (canvas.width > 0) { + var opacity = canvas.parentNode.style.opacity; + mapContext.globalAlpha = opacity === '' ? 1 + : Number(opacity); + var transform = canvas.style.transform; + // Get the transform parameters from the style's transform matrix + var matrix = transform.match(/^matrix\(([^\(]*)\)$/)[1] + .split(',').map(Number); + // Apply the transform to the export map context + CanvasRenderingContext2D.prototype.setTransform.apply( + mapContext, matrix); + mapContext.drawImage(canvas, 0, 0); + } + }); + if (navigator.msSaveBlob) { + // link download attribute does not work on MS browsers + navigator.msSaveBlob(mapCanvas.msToBlob(), 'map.png'); + } else { + console.log('qui'); +// var link = document.getElementById('image-download'); +// link.href = mapCanvas.toDataURL(); + window.open(mapCanvas.toDataURL(),'_blank'); + } + }); + map.renderSync(); + }-*/; + }