From bb9280090fd040c0f4d39715a0ba338cfce51f44 Mon Sep 17 00:00:00 2001 From: lang Date: Tue, 26 Apr 2016 12:50:47 +0800 Subject: [PATCH] Optimize MapDraw with compoundPath --- src/component/helper/MapDraw.js | 19 +++++++++++-------- src/util/graphic.js | 2 ++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/component/helper/MapDraw.js b/src/component/helper/MapDraw.js index fa0fd0b86..1aa8ba825 100644 --- a/src/component/helper/MapDraw.js +++ b/src/component/helper/MapDraw.js @@ -128,6 +128,12 @@ define(function (require) { zrUtil.each(geo.regions, function (region) { var regionGroup = new graphic.Group(); + var compoundPath = new graphic.CompoundPath({ + shape: { + paths: [] + } + }); + regionGroup.add(compoundPath); var dataIdx; // Use the itemStyle in data if has data if (data) { @@ -162,18 +168,15 @@ define(function (require) { var polygon = new graphic.Polygon({ shape: { points: contour - }, - style: { - strokeNoScale: true - }, - culling: true + } }); - polygon.setStyle(itemStyle); - - regionGroup.add(polygon); + compoundPath.shape.paths.push(polygon); }); + compoundPath.setStyle(itemStyle); + compoundPath.style.strokeNoScale = true; + compoundPath.culling = true; // Label var showLabel = labelModel.get('show'); var hoverShowLabel = hoverLabelModel.get('show'); diff --git a/src/util/graphic.js b/src/util/graphic.js index 9ba7adf1f..ea9cb0936 100644 --- a/src/util/graphic.js +++ b/src/util/graphic.js @@ -38,6 +38,8 @@ define(function(require) { graphic.Arc = require('zrender/graphic/shape/Arc'); + graphic.CompoundPath = require('zrender/graphic/CompoundPath'); + graphic.LinearGradient = require('zrender/graphic/LinearGradient'); graphic.RadialGradient = require('zrender/graphic/RadialGradient'); -- GitLab