Skip to content

Commit 02d8a85

Browse files
authored
Merge pull request #76 from ttobis/master
Updated example with Polyline arrows to work with both engine types
2 parents 0e3a24c + 7cfc518 commit 02d8a85

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

search-match-fts/demo.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ router.calculateRoute(
104104
});
105105
})
106106

107-
// create route poly;line
107+
// create route polyline
108108
routeShape.forEach(function(point) {
109109
var parts = point.split(',');
110110
lineString.pushLatLngAlt(parts[0], parts[1]);
@@ -113,15 +113,35 @@ router.calculateRoute(
113113
style: {
114114
lineWidth: 8,
115115
strokeColor: 'rgba(0, 128, 255, 0.7)'
116-
},
117-
arrows: new H.map.ArrowStyle()
116+
}
118117
});
119118

120119
map.addObject(polyline);
121120
map.getViewModel().setLookAtData({
122121
bounds: polyline.getBoundingBox()
123122
});
124123

124+
// add arrows to show route direction
125+
// for default WEBGL engine we add dashed polyline on top of our route polyline
126+
if (map.getEngine() instanceof H.map.render.webgl.RenderEngine) {
127+
var dashedPolyline = new H.map.Polyline(lineString, {
128+
style: {
129+
lineWidth: 10,
130+
strokeColor: 'rgba(130, 28, 155, 0.9)',
131+
lineDash: [1, 5],
132+
lineDashOffset: 15,
133+
lineHeadCap: 'arrow-head',
134+
lineTailCap: 'arrow-tail'
135+
}
136+
});
137+
map.addObject(dashedPolyline);
138+
} // for legacy P2D engine we call #setArrows method on polyline
139+
else if (map.getEngine() instanceof H.map.render.p2d.RenderEngine) {
140+
polyline.setArrows(new H.map.ArrowStyle({
141+
fillColor: 'rgba(130, 28, 155, 0.9)'
142+
}));
143+
}
144+
125145
findStations(linkids, polyline)
126146
},
127147
function() {

0 commit comments

Comments
 (0)