[gnome-maps/wip/osrm-routing: 11/24] Set champlain layers invisible before modifying them



commit d9f174599dca1ef3985b709c196ab4bf295c7c6e
Author: Jussi Kukkonen <jku goto fi>
Date:   Mon Apr 22 16:29:42 2013 +0300

    Set champlain layers invisible before modifying them
    
    This improves performance as otherwise the canvas gets repainted on
    every change.

 src/mapView.js |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/src/mapView.js b/src/mapView.js
index 075d15c..102030d 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -94,6 +94,10 @@ const MapView = new Lang.Class({
         let fromLocation = this._userLocation;
         let router = new osrm.Router();
 
+        // modify layers while not visible to avoid repaints
+        this._routeLayer.visible = false;
+        this._instructionsLayer.visible = false;
+
         this._routeLayer.remove_all();
         this._instructionsLayer.remove_all();
 
@@ -109,6 +113,7 @@ const MapView = new Lang.Class({
             log("Got a " +route.length+ "m route with " + route.points.length + " nodes and " +
                 route.instructions.length + " turn instructions.");
 
+
             for (let i = 0; i < route.points.length; i++) {
                 let coord = new Champlain.Coordinate();
                 coord.set_location(route.points[i]._lat,
@@ -123,8 +128,9 @@ const MapView = new Lang.Class({
                                    route.instructions[i]._lon);
                 this._instructionsLayer.add_marker(coord);
             }
-            this._routeLayer.set_visible(true);
 
+            this._routeLayer.visible = true;
+            this._instructionsLayer.visible = true;
             this.ensureVisible([fromLocation, toLocation]);
         }));
     },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]