Hi ThinkGeo Team,
Can you please give me a C# sample code for web edition showing how PagePrinterLayer can be used to render a map that contains title, scale, legend, and datagrid layers, ready to be exported to pdf for printing?
Best Regards,
Vincent
PagePrinterLayer
Hi Vincent,
Sorry to say there is no such sample codes for Web Edition. But I guess the sample “HowDoI=>Extending=>UsePdfExtension” and the method “Map1.GetBitmap” might be helpful. More details about the printing system, please refer to thinkgeo.com/forums/MapSuite/tabid/143/aft/9494/Default.aspx
Thanks,
Johnny
Hi Johnny,
Thank you for the reply. Basically I can export a map to pdf, but my problem is how to add overlays for DataGridPrinterLayer, LegendPrinterLayer, and LabelPrinterLayer to my map on the web application. I have attached a file with the code through which I have been attempting to load a map along with a data grid. When the code runs only map layer appears, while the data grid does not although when traced from the run time code it seems to be getting populated with the data.
Can you please, look at the code and suggest where I am doing wrong?
Best Regards,
Vincent
004_003_002_001_MyCode.txt (8.5 KB)
Hi Johnny,
I have managed to get the data grid and tiltle layers visible. Now my problem is when I add PostgreSqlFeatureLayer to MapPrinterLayer (see the attached code) the map from that PostgreSqlFeatureLayer does not display at all. Or is there any alternative way I can use to set position of a feature layer so that it aligns properly with other layers e.g. data grid, title, etc.?
Best Regards,
Vincent
005_004_003_002_001_MyCode.txt (8.05 KB)
Hi Vincent,
Sorry for the waiting. I checked your codes and found the MapExtent of the mapPrinterLayer is missing. After setting this property, the postgreLayer or any feature layers should be visible. Try the below codes:
MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();
mapPrinterLayer.MapUnit = GeographyUnit.Meter;
postgreLayer.Open();
mapPrinterLayer.MapExtent = postgreLayer.GetBoundingBox();
mapPrinterLayer.Open();
if the issue persists, please feel free to let us know.
Regards,
Troy
Hi Johnny,
Thank you for the reply. I have tried to set the extent and still the postgreLayer is not showing up.
Best Regards,
Vincent
Hi Vincent,
I attached the codes based on yours, some differences are I am using the mssqlfeature layer instead of postgreLayer, but I don’t think it is a big case. Would you please get the codes and do a comparison with yours?
I can get the below results:
If the issue persists, please feel free to let us know.
Thanks,
Troy
LoadAShapeFileFeatureLayer.aspx.cs (8.65 KB)
Hi Johnny,
Thank you. The solution has worked.
I have another issue. Is there any way of making the DataGridPrinterLayer content extend to multiple pages (i.e. scrow view) in case it is comprised of hundreds of rows?
Best Regards,
Vincent
Hi Vincent,
Good to hear the printing issue have been solved.
As for the second question, I am afraid there is no such function for that. I just guess if we can work with the help of EXCEL which is good at the large number of data and also easy to print anything in it.
Thanks,
Troy
Hi Support Team,
I have encountered another challenge.
When a feature layer (e.g. PostgreSqlFeatureLayer)is
directly added to an overlay object, the resulting map zooms well using custom
zoom levels. But when the same feature layer is added to mapPrinterlayer, and
then the mapPrinterlayer is added to the overlay object, the resulting map
switches to the default zoom levels instead of the custom zoom levels. To illustrate the challenge I have attached to screen shots from my application (Case1 and Case2)
Case1 shows how the map looks like when it is loaded (by adding a feature layer to the mapPrinterlayer and then add it to overlay) at first before applying any zooming or panning. You can see the room left for zooming is very minimal. Case2 shows how the map looks like when it is loaded (by directly adding feature layer to the overlay) at first before applying any zooming or panning. You can see from the image there is plenty of room to zoom the map.
Can you help me with some means to make case1 have more zooming room like case two?
Best Regards,
Vincent
Hi Vincent,
It looks we missed your screen shots here and there are some strange words which looks like style.
Could you please upload attachment files again?
Regards,
Don
Case 1
Case 2
Hi Vincent,
I think there does might be some confusions on the panzoombar’s behavior but makes sense, please let me explain it:
For the case 1, the whole map actually is a print map which we can treat it as a page/paper and the panzoombar here is just use to pan or zoom the paper’s extent. At this case, there is not any relationships between the layer’s extent and the paper’s extent.
For the case 2, the map’s extent now is corresponding with the layer’s extent and that makes everything is fine.
Most of time, we split the above into two pages, one is for the normal map view and the other one is for printing. In the printing page, we can use the customzoomlevel instead of the default zoomlevels to make the panzoombar minimize.
Hope the explain is clear.
Regards,
Troy