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



commit a35ebceff41af72c51c943d618a04e5649da3ff1
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 69a5505..8f33f2c 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -92,6 +92,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();
 
@@ -107,6 +111,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,
@@ -121,8 +126,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]