[Commits] r1536 - in sandbox/ahocevar/playground/ux/Printing: examples ux/data
commits at geoext.org
commits at geoext.org
Wed Dec 2 01:49:45 CET 2009
Author: ahocevar
Date: 2009-12-02 01:49:45 +0100 (Wed, 02 Dec 2009)
New Revision: 1536
Modified:
sandbox/ahocevar/playground/ux/Printing/examples/Printing.html
sandbox/ahocevar/playground/ux/Printing/examples/Printing.js
sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js
Log:
added vector drawing capabilities to show vector printing
Modified: sandbox/ahocevar/playground/ux/Printing/examples/Printing.html
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/Printing.html 2009-12-02 00:25:31 UTC (rev 1535)
+++ sandbox/ahocevar/playground/ux/Printing/examples/Printing.html 2009-12-02 00:49:45 UTC (rev 1536)
@@ -14,5 +14,6 @@
<script type="text/javascript" src="http://demo.mapfish.org/mapfishsample/1.2/print/info.json?var=printCapabilities"></script>
</head>
<body>
+ <a href="javascript:printProvider.print()">Print</a>
</body>
</html>
Modified: sandbox/ahocevar/playground/ux/Printing/examples/Printing.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/examples/Printing.js 2009-12-02 00:25:31 UTC (rev 1535)
+++ sandbox/ahocevar/playground/ux/Printing/examples/Printing.js 2009-12-02 00:49:45 UTC (rev 1536)
@@ -8,17 +8,28 @@
method: "GET"
});
+ var redline = new OpenLayers.Layer.Vector("vector", {
+ styleMap: new OpenLayers.StyleMap({
+ strokeColor: "red",
+ fillColor: "red",
+ fillOpacity: 0.5,
+ strokeWidth: 2,
+ pointRadius: 6
+ })
+ });
var mapPanel = new GeoExt.MapPanel({
renderTo: document.body,
width: 500,
height: 300,
layers: [new OpenLayers.Layer.WMS("Global Imagery",
"http://labs.metacarta.com/wms/vmap0",
- {layers: "basic"})] ,
+ {layers: "basic"}), redline] ,
center: [16,48],
zoom: 5
});
+ mapPanel.map.addLayer(redline);
+ var draw = new OpenLayers.Control.DrawFeature(redline, OpenLayers.Handler.Polygon);
+ mapPanel.map.addControl(draw);
+ draw.activate();
- printProvider.print();
-
});
Modified: sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js
===================================================================
--- sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js 2009-12-02 00:25:31 UTC (rev 1535)
+++ sandbox/ahocevar/playground/ux/Printing/ux/data/PrintProvider.js 2009-12-02 00:49:45 UTC (rev 1536)
@@ -232,56 +232,59 @@
};
},
"Vector": function(layer) {
- var encFeatures = [];
- var encStyles = {};
- var features = layer.features;
- var featureFormat = new OpenLayers.Format.GeoJSON();
- var styleFormat = new OpenLayers.Format.JSON();
- var nextId = 1;
- var a = document.createElement("a");
- var feature, style, styleDict, dictKey, dictItem;
- for(var i=0, len=features.length; i<len; ++i) {
- feature = features[i];
- style = feature.style || layer.style ||
- layer.styleMap.createSymbolizer(feature, feature.renderIntent);
- dictKey = styleFormat.write(style);
- dictItem = styleDict[dictKey];
- if (dictItem) {
- //this style is already known
- styleName = dictItem;
- } else {
- //new style
- styleDict[dictKey] = styleName = nextId++;
- if (style.externalGraphic) {
- //Make the URLs absolute
- a.href = style.externalGraphic;
- encStyles[styleName] = Ext.apply({
- externalGraphic: a.href
- }, style);
+ if(layer.features.length) {
+ var encFeatures = [];
+ var encStyles = {};
+ var features = layer.features;
+ var featureFormat = new OpenLayers.Format.GeoJSON();
+ var styleFormat = new OpenLayers.Format.JSON();
+ var nextId = 1;
+ var a = document.createElement("a");
+ var styleDict = {};
+ var feature, style, dictKey, dictItem;
+ for(var i=0, len=features.length; i<len; ++i) {
+ feature = features[i];
+ style = feature.style || layer.style ||
+ layer.styleMap.createSymbolizer(feature, feature.renderIntent);
+ dictKey = styleFormat.write(style);
+ dictItem = styleDict[dictKey];
+ if (dictItem) {
+ //this style is already known
+ styleName = dictItem;
} else {
- encStyles[styleName] = style;
+ //new style
+ styleDict[dictKey] = styleName = nextId++;
+ if (style.externalGraphic) {
+ //Make the URLs absolute
+ a.href = style.externalGraphic;
+ encStyles[styleName] = Ext.apply({
+ externalGraphic: a.href
+ }, style);
+ } else {
+ encStyles[styleName] = style;
+ }
}
+ var featureGeoJson = featureFormat.extract.feature.call(
+ featureFormat, feature);
+
+ featureGeoJson.properties = OpenLayers.Util.extend({
+ _gx_style: styleName
+ }, featureGeoJson.properties);
+
+ encFeatures.push(featureGeoJson);
}
- var featureGeoJson = featureFormat.extract.feature.call(
- featureFormat, feature);
-
- featureGeoJson.properties = OpenLayers.Util.extend({
- _gx_style: styleName
- }, featureGeoJson.properties);
-
- encFeatures.push(featureGeoJson);
+
+ return {
+ type: 'Vector',
+ styles: encStyles,
+ styleProperty: '_gx_style',
+ geoJson: {
+ type: "FeatureCollection",
+ features: encFeatures
+ },
+ name: layer.name,
+ opacity: (layer.opacity != null) ? layer.opacity : 1.0
+ };
}
-
- return {
- type: 'Vector',
- styles: encStyles,
- styleProperty: '_gx_style',
- geoJson: {
- type: featureCollection,
- features: encFeatures
- },
- name: olLayer.name,
- opacity: (olLayer.opacity != null) ? olLayer.opacity : 1.0
- };
}
};
\ No newline at end of file
More information about the Commits
mailing list