I don't have any physical code that can be shared, but I can tell you what I
did in order to get it to work. You can probably apply this to whatever
programming language you are using.
We are using ASP.NET and took advantage of the System.Drawing namespace to draw
the vectors back on the image.
Here's the client code that I am able to share:
$j.each(layer.features, function() {
if (this.onScreen() == true) {
/* it's on screen */
var opacity = layer.opacity ? parseInt(100 *
layer.opacity) : 100;
/* get the coordinates, remove any non coordinate
text and split it at the comma's */
var coords =
this.geometry.toString().replace(/[^\d\,\s\.]*/gi, "").split(",");
var vectorCoords = [];
$j.each(coords, function() {
/* get the screen coord */
var xy = this.split(" ");
var screen = map.getLayerPxFromLonLat(new
OpenLayers.LonLat(xy[0], xy[1]));
vectorCoords.push({ x: screen.x, y: screen.y });
});
/* the server needs to know what type of vector it
has to draw */
var vectorType = "";
if (this.geometry.CLASS_NAME.search(/polygon$/i) >=
0) {
vectorType = "polygon";
} else if
(this.geometry.CLASS_NAME.search(/point$/i) >= 0) {
vectorType = "point";
} else if
(this.geometry.CLASS_NAME.search(/linestring$/i) >= 0) {
vectorType = "line";
} else {
vectorType = "unknown";
}
var vectorLabel;
try {
if (typeof (this.attributes.label) !=
"undefined") {
vectorLabel = this.attributes.label;
} else {
/* no label */
vectorLabel = "";
}
} catch (e) { vectorLabel = ""; }
vectors.push({ t: vectorType, o: opacity, c:
vectorCoords, l: vectorLabel });
}
});
The code goes through each feature in my infoLayer, and then goes through each
coordinate in each feature and pulls the client side x / y out. It checks for
any possible labels and sends the vector type (poly, line, etc.) to the server
via JSON.
On the server, it takes the x/y and just uses that to draw the vectors onto the
image on the server side.
The server then goes through each vector object (from the client side vectors
array) and takes the coordinates (c) and using the System.Drawing.Graphic class
(DrawLines, DrawEllipse, FillRectangle, etc), it draws the lines/poly's/circles
on the in-memory (system.drawing.bitmap) object. Hopefully this will give you
a kick in the right direction to get you started.
If you are not a .net person, at least the client side code will get you
thinking.
Shawn
>>> On 4/26/2010 at 3:29 PM, guillaumev <[email protected]> wrote:
Hi,
soatley > I'm trying to do the exact same thing (server side stitching of
the different layers of the map). However, after using the code here:
http://trac.openlayers.org/wiki/Printing, the vector layers do NOT get
printed. Do you have some reusable code that you would be willing to share,
in order to properly print the vector layers ? Thank you.
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/How-to-print-map-area-with-openlayers-tp4901023p4964522.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users