draw complex LineString in interaction mode openlayers-3

المشرف العام

Administrator
طاقم الإدارة
I'm trying to modify a linestring after the user clicked on the map in order to calculate best route from last point to clicked point using a routing algorithm (getRoute). The following code is not working as expected... Have you ever try to do this?

me.drawFollowingPathMode = false;var olDraw = new ol.interaction.Draw({ source: source, type: geometry, geometryFunction: function(coords, geom) { if (!geom) { geom = new ol.geom.LineString(null); } if (!me.drawFollowingPathMode) { $('#map').on('mouseup', function () { var len = coords.length; if (len > 1) { var start = coords[len - 2]; var end = coords[len - 1]; getRoute(start, end).then(function (route) { coords = coords.slice(0, len - 1); coords = coords.concat(route); geom.setCoordinates(coords); me.drawFollowingPathMode = false; }); } }); me.drawFollowingPathMode = true; } else { geom.setCoordinates(coords); } return geom; }});

أكثر...
 
أعلى