[gnome-maps] printLayout: Add markers to route
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] printLayout: Add markers to route
- Date: Thu, 25 Feb 2016 19:15:44 +0000 (UTC)
commit b8dfaabec9c036acb495bb622d7463eefaf23bcb
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Wed Feb 24 09:08:32 2016 +0100
printLayout: Add markers to route
https://bugzilla.gnome.org/show_bug.cgi?id=762303
src/longPrintLayout.js | 16 ++++++++--------
src/printLayout.js | 34 +++++++++++++++++++++++++---------
2 files changed, 33 insertions(+), 17 deletions(-)
---
diff --git a/src/longPrintLayout.js b/src/longPrintLayout.js
index 22ae720..5e99057 100644
--- a/src/longPrintLayout.js
+++ b/src/longPrintLayout.js
@@ -64,17 +64,17 @@ const LongPrintLayout = new Lang.Class({
let miniMapViewZoomLevel = _MiniMapView.ZOOM_LEVEL;
let dy = 0;
- let locationsLength = this._route.turnPoints.length;
+ let turnPointsLength = this._route.turnPoints.length;
/* Fixed number of locations are plotted on minimaps which requires a
* check on instructions bound. Later on this can be made dynamic
* depending upon factors like total number of instructions, complexity
* of neighbourhood areas, etc.
*/
- let nthStartLocation = Math.min(_NUM_MINIMAPS, locationsLength);
- let startLocations = this._createLocationArray(0, nthStartLocation);
+ let nthStartTurnPoints = Math.min(_NUM_MINIMAPS, turnPointsLength);
+ let startTurnPoints = this._createTurnPointArray(0, nthStartTurnPoints);
this._drawMapView(miniMapViewWidth, miniMapViewHeight,
- miniMapViewZoomLevel, startLocations);
+ miniMapViewZoomLevel, startTurnPoints);
/* x-cursor is increased temporarily for rendering instructions */
let tmpX = this._cursorX;
@@ -88,11 +88,11 @@ const LongPrintLayout = new Lang.Class({
}.bind(this));
this._cursorX = tmpX;
- let firstEndLocation = Math.max(0, locationsLength - _NUM_MINIMAPS);
- let endLocations = this._createLocationArray(firstEndLocation,
- locationsLength);
+ let firstEndTurnPoint = Math.max(0, turnPointsLength - _NUM_MINIMAPS);
+ let endTurnPoints = this._createTurnPointArray(firstEndTurnPoint,
+ turnPointsLength);
this._cursorY = Math.max(0, this._cursorY - miniMapViewHeight);
this._drawMapView(miniMapViewWidth, miniMapViewHeight,
- miniMapViewZoomLevel, endLocations);
+ miniMapViewZoomLevel, endTurnPoints);
}
});
diff --git a/src/printLayout.js b/src/printLayout.js
index b4e72fa..8fc2a02 100644
--- a/src/printLayout.js
+++ b/src/printLayout.js
@@ -28,7 +28,6 @@ const PangoCairo = imports.gi.PangoCairo;
const Application = imports.application;
const InstructionRow = imports.instructionRow;
-const MapMarker = imports.mapMarker;
const MapView = imports.mapView;
const TurnPointMarker = imports.turnPointMarker;
@@ -125,10 +124,10 @@ const PrintLayout = new Lang.Class({
dy = mapViewHeight + mapViewMargin;
this._adjustPage(dy);
- let locationsLength = this._route.turnPoints.length;
- let allLocations = this._createLocationArray(0, locationsLength);
+ let turnPointsLength = this._route.turnPoints.length;
+ let allTurnPoints = this._createTurnPointArray(0, turnPointsLength);
this._drawMapView(mapViewWidth, mapViewHeight,
- mapViewZoomLevel, allLocations);
+ mapViewZoomLevel, allTurnPoints);
this._cursorY += dy;
},
@@ -138,19 +137,36 @@ const PrintLayout = new Lang.Class({
}).bind(this));
},
- _drawMapView: function(width, height, zoomLevel, locations) {
+ _createMarker: function(turnPoint) {
+ return new TurnPointMarker.TurnPointMarker({
+ turnPoint: turnPoint,
+ queryPoint: {}
+ });
+ },
+
+ _drawMapView: function(width, height, zoomLevel, turnPoints) {
let pageNum = this.numPages - 1;
let x = this._cursorX;
let y = this._cursorY;
let factory = Champlain.MapSourceFactory.dup_default();
let mapSource = factory.create_cached_source(MapView.MapType.STREET);
+ let locations = [];
+ let markerLayer = new Champlain.MarkerLayer();
let view = new Champlain.View({ width: width,
height: height,
zoom_level: zoomLevel });
view.set_map_source(mapSource);
+ view.add_layer(markerLayer);
this._addRouteLayer(view);
+ turnPoints.forEach((function(turnPoint) {
+ locations.push(turnPoint.coordinate);
+ if (turnPoint.isStop()) {
+ markerLayer.add_marker(this._createMarker(turnPoint));
+ }
+ }).bind(this));
+
view.ensure_visible(this._route.createBBox(locations), false);
if (view.state !== Champlain.State.DONE) {
let notifyId = view.connect('notify::state', (function() {
@@ -168,12 +184,12 @@ const PrintLayout = new Lang.Class({
}
},
- _createLocationArray: function(startIndex, endIndex) {
- let locationArray = [];
+ _createTurnPointArray: function(startIndex, endIndex) {
+ let turnPointArray = [];
for (let i = startIndex; i < endIndex; i++) {
- locationArray.push(this._route.turnPoints[i].coordinate);
+ turnPointArray.push(this._route.turnPoints[i]);
}
- return locationArray;
+ return turnPointArray;
},
_addRouteLayer: function(view) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]