GNOME Bugzilla – Bug 760352
Make sure our markers gets exported to PNG/print
Last modified: 2016-01-12 19:47:35 UTC
Champlain can now export to a cairo surface. It is not magic. It can only export tiles and layers that implement the ChamplainExportable interface. I have patches pending to make the MarkerLayer implement the interface. When/if they land we can make sure our own markers are exportable. That means they need to be able to export their content to a cairo surface.
Created attachment 318571 [details] [review] Implement ChamplainExportable interface for markers This cycle we added a way to export the ChamplainView to a cairo surface. This is meant as way of creating PNG images of our map. As well as a way to facilitate printing of the map view. The cairo_view_to_surface function will go through each ChamplainLayer added to the view and check if it implements ChamplainExportable, and add it to the final surface if it does. The ChamplainMarkerLayer will only export surface if the markers within implements ChamplainExportable. Let's make it so.
Created attachment 318572 [details] Exported PNG from route before patch
Created attachment 318573 [details] Exported PNG from route after patch
Review of attachment 318571 [details] [review]: Small comments, but looks good otherwise. Still, this patch doesn't seem to work on my system. I have up-to-date libchamplain and gnome-maps, but the exported image only has the base map layer (no markers, no blue circle for gps, etc). Not sure why. ::: src/mapMarker.js @@ +120,3 @@ + + return actor; + } catch(e) { space before ( (says gjslint) @@ +121,3 @@ + return actor; + } catch(e) { + Utils.debug("Failed to load image: " + e.message); Should be 'single quoted' because it's not translated. ::: src/placeMarker.js @@ +33,3 @@ this.parent(params); + this.add_actor(this._actorFromIconName('mark-location', 32)); Utils is no longer needed as an import. ::: src/userLocationMarker.js @@ +73,2 @@ if (this.place.location.heading > -1) { + let actor = this._actorFromIconName('user-location-compass', 0); Likewise Utils not used anymore here ::: src/utils.js @@ +162,2 @@ } Clutter and Cogl imports are no longer used
Review of attachment 318571 [details] [review]: Thanks for review Hashem! ::: src/mapMarker.js @@ +120,3 @@ + + return actor; + null, null)[0]; I see, we do not seem to follow that in rest of Maps, or rather we are not consistent, we do sometimes. We might as well follow gjslin then I guess :) [...] src/application.js: } catch(e) { src/application.js: } catch (e) { src/exportViewDialog.js: } catch(e) { src/exportViewDialog.js: } catch(e) { src/geoclue.js: catch (e) { src/geocodeService.js: } catch (e) { src/geocodeService.js: } catch (e) { src/locationServiceNotification.js: } catch(e) { [...] @@ +121,3 @@ + return actor; + } catch(e) { + null, null)[0]; Right you are.
Created attachment 318708 [details] [review] Implement ChamplainExportable interface for markers This cycle we added a way to export the ChamplainView to a cairo surface. This is meant as way of creating PNG images of our map. As well as a way to facilitate printing of the map view. The cairo_view_to_surface function will go through each ChamplainLayer added to the view and check if it implements ChamplainExportable, and add it to the final surface if it does. The ChamplainMarkerLayer will only export surface if the markers within implements ChamplainExportable. Let's make it so.
Attachment 318708 [details] pushed as 625b545 - Implement ChamplainExportable interface for markers