Skip to content

Commit 58f4084

Browse files
committed
2 parents 1b41aed + 4ac382d commit 58f4084

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

Samples/Services Module/Draggable route lines/Draggable route lines.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,16 @@
8787
//Create a layer for rendering the route line.
8888
var routeLayer = new atlas.layer.LineLayer(routeDS, null, {
8989
strokeColor: '#2272B9',
90-
strokeWidth: 5,
90+
strokeWidth: 10,
9191
lineJoin: 'round',
9292
lineCap: 'round'
9393
});
9494

9595
//Add a mouse down event to the route line layer so that mid-point waypoints can be added to the route.
9696
map.events.add('mousedown', routeLayer, routeMouseDown);
97+
98+
//Use touch start event on map directly as it triggers faster than layer level touch events.
99+
map.events.add('touchstart', mapTouchStart);
97100

98101
//When the mouse is over the route layer, change the cursor to be a pointer.
99102
map.events.add('mouseover', routeLayer, function () {
@@ -120,9 +123,11 @@
120123

121124
//Track the movement of the mouse on the map for better dragging of the route line with a new mid-point.
122125
map.events.add('mousemove', mouseMoved);
126+
map.events.add('touchmove', mouseMoved);
123127

124128
//Track when the mouse event fires to clear the mouseDownOnRoute flag.
125129
map.events.add('mouseup', mouseUp);
130+
map.events.add('touchend', mouseUp);
126131

127132
//Calculate initial directions.
128133
calculateDirections();
@@ -206,6 +211,14 @@
206211
}
207212

208213
function markerDragged(e) {
214+
//NOTE: The next two lines below are the same as markerMouseDown event, but needed here for touch support.
215+
216+
//Disable event bubbling so that if marker overlaps line, a new mid-point isn't also added.
217+
skipMidPointAdd = true;
218+
219+
//Track the active waypoint index.
220+
activeWaypointIdx = e.target.properties.wpIdx;
221+
209222
//Update the position of the corresponding waypoint.
210223
waypoints[activeWaypointIdx] = e.target.getOptions().position;
211224

@@ -347,6 +360,15 @@
347360

348361
return routeIdx;
349362
}
363+
364+
function mapTouchStart(e) {
365+
//Check that if a route path exists.
366+
//Check to see if touch event occured on the route line.
367+
if (routePath && e.shapes && e.shapes.length > 0 && e.shapes[0] && e.shapes[0] instanceof atlas.Shape && routeDS.getShapeById(e.shapes[0].getId())) {
368+
//Now that we know the touch event happended on a route line, call the route mouse down event.
369+
routeMouseDown(e);
370+
}
371+
}
350372
</script>
351373
</head>
352374
<body onload="GetMap()">

Samples/Spatial Analysis/Calculate nearest locations/Calculate nearest locations.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
ignorePlacement: true
123123
},
124124
textOptions: {
125-
textField: ['Id'],
125+
textField: ['id'],
126126
color: 'white',
127127
size: 12,
128128
offset: [0, 0.4],

0 commit comments

Comments
 (0)