Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@2gis/mapgl-directions

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@2gis/mapgl-directions - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

2

dist/directions.js

@@ -1,1 +0,1 @@

!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var r=e();for(var n in r)("object"==typeof exports?exports:t)[n]=r[n]}}(window,(function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=1)}([function(t,e){t.exports=i,t.exports.parse=i,t.exports.stringify=function t(e){"Feature"===e.type&&(e=e.geometry);function r(t){return t.join(" ")}function n(t){return t.map(r).join(", ")}function i(t){return t.map(n).map(o).join(", ")}function o(t){return"("+t+")"}switch(e.type){case"Point":return"POINT ("+r(e.coordinates)+")";case"LineString":return"LINESTRING ("+n(e.coordinates)+")";case"Polygon":return"POLYGON ("+i(e.coordinates)+")";case"MultiPoint":return"MULTIPOINT ("+n(e.coordinates)+")";case"MultiPolygon":return"MULTIPOLYGON ("+(e.coordinates.map(i).map(o).join(", ")+")");case"MultiLineString":return"MULTILINESTRING ("+i(e.coordinates)+")";case"GeometryCollection":return"GEOMETRYCOLLECTION ("+e.geometries.map(t).join(", ")+")";default:throw new Error("stringify requires a valid GeoJSON Feature or geometry object as input")}};var r=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,n=new RegExp("^"+r.source+"(\\s"+r.source+"){1,}");function i(t){var e,r=t.split(";"),i=r.pop(),o=(r.shift()||"").split("=").pop(),s=0;function a(t){var e=i.substring(s).match(t);return e?(s+=e[0].length,e[0]):null}function u(){a(/^\s*/)}function l(){u();for(var t,e=0,r=[],i=[r],o=r;t=a(/^(\()/)||a(/^(\))/)||a(/^(,)/)||a(n);){if("("===t)i.push(o),o=[],i[i.length-1].push(o),e++;else if(")"===t){if(0===o.length)return null;if(!(o=i.pop()))return null;if(0===--e)break}else if(","===t)o=[],i[i.length-1].push(o);else{if(t.split(/\s/g).some(isNaN))return null;Array.prototype.push.apply(o,t.split(/\s/g).map(parseFloat))}u()}return 0!==e?null:r}function d(){for(var t,e,r=[];e=a(n)||a(/^(,)/);)","===e?(r.push(t),t=[]):e.split(/\s/g).some(isNaN)||(t||(t=[]),Array.prototype.push.apply(t,e.split(/\s/g).map(parseFloat))),u();return t?(r.push(t),r.length?r:null):null}function p(){return function(){if(!a(/^(point(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var t=d();return t?(u(),a(/^(\))/)?{type:"Point",coordinates:t[0]}:null):null}()||function(){if(!a(/^(linestring(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var t=d();return t&&a(/^(\))/)?{type:"LineString",coordinates:t}:null}()||function(){if(!a(/^(polygon(\sz)?)/i))return null;u();var t=l();return t?{type:"Polygon",coordinates:t}:null}()||function(){if(!a(/^(multipoint)/i))return null;u();var t=i.substring(i.indexOf("(")+1,i.length-1).replace(/\(/g,"").replace(/\)/g,"");i="MULTIPOINT ("+t+")";var e=l();return e?(u(),{type:"MultiPoint",coordinates:e}):null}()||function(){if(!a(/^(multilinestring)/i))return null;u();var t=l();return t?(u(),{type:"MultiLineString",coordinates:t}):null}()||function(){if(!a(/^(multipolygon)/i))return null;u();var t=l();return t?{type:"MultiPolygon",coordinates:t}:null}()||function(){var t,e=[];if(!a(/^(geometrycollection)/i))return null;if(u(),!a(/^(\()/))return null;for(;t=p();)e.push(t),u(),a(/^(,)/),u();return a(/^(\))/)?{type:"GeometryCollection",geometries:e}:null}()}return(e=p())&&o.match(/\d+/)&&(e.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+o}}),e}},function(t,e,r){"use strict";r.r(e),r.d(e,"Directions",(function(){return g}));var n=0,i=1,o={fast:"#22aa01",normal:"#ffc402",slow:"#f72000","slow-jams":"#81020d","no-traffic":"#0f6ec1",ignore:"#0f6ec1",pedestrian:"#626262","pedestrian-underground":"#626262",inactive:"#b4bcd2",border:"#ffffff",border2:"#ff141414",hovered:"#000000"},s={size:[22,22],offset:[11,11],img:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHZpZXdCb3g9IjAgMCAyMiAyMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBmaWxsPSIjMDAwMDAwIiBmaWxsLW9wYWNpdHk9IjAuMTUiIGQ9Ik0xMSAyMkMxNy4wNzUxIDIyIDIyIDE3LjA3NTEgMjIgMTFDMjIgNC45MjQ4NyAxNy4wNzUxIDAgMTEgMEM0LjkyNDg3IDAgMCA0LjkyNDg3IDAgMTFDMCAxNy4wNzUxIDQuOTI0ODcgMjIgMTEgMjJaIi8+CiAgPHBhdGggZmlsbD0iI2ZmZmZmZiIgZD0iTTExIDIxQzE2LjUyMjggMjEgMjEgMTYuNTIyOCAyMSAxMUMyMSA1LjQ3NzE1IDE2LjUyMjggMSAxMSAxQzUuNDc3MTUgMSAxIDUuNDc3MTUgMSAxMUMxIDE2LjUyMjggNS40NzcxNSAyMSAxMSAyMVoiLz4KICA8cGF0aCBmaWxsPSIjMGY2ZWMxIiBkPSJNMTEgMTlDMTUuNDE4MyAxOSAxOSAxNS40MTgzIDE5IDExQzE5IDYuNTgxNzIgMTUuNDE4MyAzIDExIDNDNi41ODE3MiAzIDMgNi41ODE3MiAzIDExQzMgMTUuNDE4MyA2LjU4MTcyIDE5IDExIDE5WiIvPgo8L3N2Zz4K"},a=14,u="#ffffff";function l(t){switch(t){case"fast":case"normal":case"slow":case"slow-jams":case"no-traffic":return t;default:return"ignore"}}function d(t){return t.map((function(e,r){var n=String(r);return 0===r&&(n="A"),r===t.length-1&&(n="B"),{position:e,label:{text:n,fontSize:a,color:u},icon:s}}))}var p=r(0),c=function(t){var e=t.base,r=t.pedestrian;return{normal:e,fast:e,ignore:e,"no-traffic":e,slow:e,"slow-jams":e,pedestrian:r,"pedestrian-underground":r,inactive:t.inactive}},h=function(t,e){return{color:e[t],hoveredColor:e.hovered,borderColor:e.border,hoveredBorderColor:e.border,border2Color:e.border2,hoveredBorder2Color:e.border2}};var f=function(){function t(t,e){this.map=t,this.settings=e,this.lineStylesCurves=function(t){var e={fast:{width:[],width2:[],width3:[]},normal:{width:[],width2:[],width3:[]},slow:{width:[],width2:[],width3:[]},"slow-jams":{width:[],width2:[],width3:[]},ignore:{width:[],width2:[],width3:[]},"no-traffic":{width:[],width2:[],width3:[]},pedestrian:{width:[],width2:[],width3:[]},"pedestrian-underground":{width:[],width2:[],width3:[]},inactive:{width:[],width2:[],width3:[]}},r=t.lineStylesByZoom;for(var n in r){var i=r[n];for(var o in i){var s=o,a=i[o];e[s].width.push([Number(n),a.width,1]),e[s].width2.push([Number(n),a.width+2*a.borderWidth,1]),e[s].width3.push([Number(n),a.width+2*(a.borderWidth+a.border2Width),1])}}return e}(e),this.polylines=[],this.markers=[],this.nextPolylinePhase=n,this.nextPointPhase=i}return t.prototype.draw=function(t){this.drawPoints(t.points),this.drawRoutes(t.routes,t.activeRouteId)},t.prototype.clear=function(){this.draw({routes:[],points:[]})},t.prototype.drawPoints=function(t){for(var e=0,r=this.markers;e<r.length;e++){(l=r[e]).destroy()}this.markers=[],this.nextPointPhase=i;for(var n=0;n<t.length;n++){var o=t[n],s=o.position,a=o.label,u=o.icon,l=new mapgl.Marker(this.map,{coordinates:s,icon:u.img,size:u.size,anchor:u.offset,zIndex:this.getNextPointPhase(),label:{text:a.text,fontSize:a.fontSize,color:a.color,anchor:[0,0],zIndex:this.getNextPointPhase()}});this.markers.push(l)}},t.prototype.drawRoutes=function(t,e){for(var r=0,i=this.polylines;r<i.length;r++){i[r].polyline.destroy()}var o;this.polylines=[],this.nextPolylinePhase=n;for(var s=0,a=t;s<a.length;s++){var u=a[s];u.id===e?o=u:this.drawRoute(u,!1)}o&&this.drawRoute(o,!0)},t.prototype.drawRoute=function(t,e){for(var r=t.id,n=t.sections,i=this.getNextPolylinePhase(),o=this.getNextPolylinePhase(),s=0,a=n;s<a.length;s++){var u=a[s],l=Object(p.parse)(u.geometry);if(l){var d=l.coordinates,c=this.settings.lineStyles,h=void 0!==c[u.type]?u.type:"inactive",f=e?h:"inactive",g=c[f],y=g.color,w=g.borderColor,m=g.border2Color,M=this.lineStylesCurves[f],v=M.width,I=M.width2,b=M.width3,x=new mapgl.Polyline(this.map,{coordinates:d,zIndex:this.getNextPolylinePhase(),zIndex2:o,zIndex3:i,color:y,color2:w,color3:m,width:v,width2:I,width3:b});this.polylines.push({routeId:r,type:f,polyline:x})}}},t.prototype.getNextPolylinePhase=function(){return this.nextPolylinePhase+=1e-6},t.prototype.getNextPointPhase=function(){return this.nextPointPhase+=1e-6},t}(),g=function(){function t(t,e){this.map=t,this.options=e;var r,n=(r=o,{lineStylesByZoom:{14:c({base:{width:5.73,borderWidth:3,border2Width:.5},pedestrian:{width:4,borderWidth:2,border2Width:.5},inactive:{width:4,borderWidth:2,border2Width:.5}}),20:c({base:{width:10.5,borderWidth:5.5,border2Width:.8},pedestrian:{width:5.5,borderWidth:3,border2Width:.5},inactive:{width:5,borderWidth:3,border2Width:.5}})},lineStyles:{normal:h("normal",r),fast:h("fast",r),ignore:h("ignore",r),"no-traffic":h("no-traffic",r),slow:h("slow",r),"slow-jams":h("slow-jams",r),pedestrian:h("pedestrian",r),"pedestrian-underground":h("pedestrian-underground",r),inactive:h("inactive",r)}});this.ppnaDrawer=new f(this.map,n)}return t.prototype.clear=function(){this.ppnaDrawer.clear(),this.map.setStyleOptions({traffic:!1})},t.prototype.carRoute=function(t){var e=this,r=t.points;if(r.length<2)throw new Error("At least two points are required");var n={type:"jam",point_a_name:"Source",point_b_name:"Target",locale:"en",points:r.map((function(t,e){return{x:t[0],y:t[1],type:0===e||e===r.length-1?"pedo":"pref"}}))};fetch("https://catalog.api.2gis.ru/carrouting/6.0.0/global?key="+this.options.directionsApiKey,{method:"post",body:JSON.stringify(n)}).then((function(t){if(200!==t.status)throw new Error("HTTP code is "+t.status);return t.json()})).then((function(t){return e.drawCarRoute(t.result||[],r)})).catch((function(t){return console.log(t)}))},t.prototype.drawCarRoute=function(t,e){var r=function(t,e){var r=[];return e.forEach((function(e){var n={id:e.id,sections:[]};e.begin_pedestrian_path&&n.sections.push({type:"pedestrian",geometry:e.begin_pedestrian_path.geometry.selection}),(e.maneuvers||[]).forEach((function(e){var r=e.outcoming_path&&e.outcoming_path.geometry;r&&r.forEach((function(e){n.sections.push({type:"pedestrian"!==t?l(e.color):"pedestrian",geometry:e.selection})}))})),e.end_pedestrian_path&&n.sections.push({type:"pedestrian",geometry:e.end_pedestrian_path.geometry.selection}),r.push(n)})),r}("ppna",t)[0];this.map.setStyleOptions({traffic:!0}),this.ppnaDrawer.draw({routes:[r],points:d(e),activeRouteId:r.id})},t}();"mapgl"in window?mapgl.Directions=g:console.error("Looks like you did not load MapGL API correctly")}])}));
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=1)}([function(e,t){e.exports=o,e.exports.parse=o,e.exports.stringify=function e(t){"Feature"===t.type&&(t=t.geometry);function n(e){return e.join(" ")}function r(e){return e.map(n).join(", ")}function o(e){return e.map(r).map(i).join(", ")}function i(e){return"("+e+")"}switch(t.type){case"Point":return"POINT ("+n(t.coordinates)+")";case"LineString":return"LINESTRING ("+r(t.coordinates)+")";case"Polygon":return"POLYGON ("+o(t.coordinates)+")";case"MultiPoint":return"MULTIPOINT ("+r(t.coordinates)+")";case"MultiPolygon":return"MULTIPOLYGON ("+(t.coordinates.map(o).map(i).join(", ")+")");case"MultiLineString":return"MULTILINESTRING ("+o(t.coordinates)+")";case"GeometryCollection":return"GEOMETRYCOLLECTION ("+t.geometries.map(e).join(", ")+")";default:throw new Error("stringify requires a valid GeoJSON Feature or geometry object as input")}};var n=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,r=new RegExp("^"+n.source+"(\\s"+n.source+"){1,}");function o(e){var t,n=e.split(";"),o=n.pop(),i=(n.shift()||"").split("=").pop(),s=0;function a(e){var t=o.substring(s).match(e);return t?(s+=t[0].length,t[0]):null}function u(){a(/^\s*/)}function l(){u();for(var e,t=0,n=[],o=[n],i=n;e=a(/^(\()/)||a(/^(\))/)||a(/^(,)/)||a(r);){if("("===e)o.push(i),i=[],o[o.length-1].push(i),t++;else if(")"===e){if(0===i.length)return null;if(!(i=o.pop()))return null;if(0===--t)break}else if(","===e)i=[],o[o.length-1].push(i);else{if(e.split(/\s/g).some(isNaN))return null;Array.prototype.push.apply(i,e.split(/\s/g).map(parseFloat))}u()}return 0!==t?null:n}function c(){for(var e,t,n=[];t=a(r)||a(/^(,)/);)","===t?(n.push(e),e=[]):t.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,t.split(/\s/g).map(parseFloat))),u();return e?(n.push(e),n.length?n:null):null}function p(){return function(){if(!a(/^(point(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var e=c();return e?(u(),a(/^(\))/)?{type:"Point",coordinates:e[0]}:null):null}()||function(){if(!a(/^(linestring(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var e=c();return e&&a(/^(\))/)?{type:"LineString",coordinates:e}:null}()||function(){if(!a(/^(polygon(\sz)?)/i))return null;u();var e=l();return e?{type:"Polygon",coordinates:e}:null}()||function(){if(!a(/^(multipoint)/i))return null;u();var e=o.substring(o.indexOf("(")+1,o.length-1).replace(/\(/g,"").replace(/\)/g,"");o="MULTIPOINT ("+e+")";var t=l();return t?(u(),{type:"MultiPoint",coordinates:t}):null}()||function(){if(!a(/^(multilinestring)/i))return null;u();var e=l();return e?(u(),{type:"MultiLineString",coordinates:e}):null}()||function(){if(!a(/^(multipolygon)/i))return null;u();var e=l();return e?{type:"MultiPolygon",coordinates:e}:null}()||function(){var e,t=[];if(!a(/^(geometrycollection)/i))return null;if(u(),!a(/^(\()/))return null;for(;e=p();)t.push(e),u(),a(/^(,)/),u();return a(/^(\))/)?{type:"GeometryCollection",geometries:t}:null}()}return(t=p())&&i.match(/\d+/)&&(t.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+i}}),t}},function(e,t,n){"use strict";n.r(t),n.d(t,"Directions",(function(){return g}));var r=0,o=1,i={fast:"#22aa01",normal:"#ffc402",slow:"#f72000","slow-jams":"#81020d","no-traffic":"#0f6ec1",ignore:"#0f6ec1",pedestrian:"#626262","pedestrian-underground":"#626262",inactive:"#b4bcd2",border:"#ffffff",border2:"#ff141414",hovered:"#000000"},s={size:[22,22],offset:[11,11],img:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjIiIGhlaWdodD0iMjIiIHZpZXdCb3g9IjAgMCAyMiAyMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBmaWxsPSIjMDAwMDAwIiBmaWxsLW9wYWNpdHk9IjAuMTUiIGQ9Ik0xMSAyMkMxNy4wNzUxIDIyIDIyIDE3LjA3NTEgMjIgMTFDMjIgNC45MjQ4NyAxNy4wNzUxIDAgMTEgMEM0LjkyNDg3IDAgMCA0LjkyNDg3IDAgMTFDMCAxNy4wNzUxIDQuOTI0ODcgMjIgMTEgMjJaIi8+CiAgPHBhdGggZmlsbD0iI2ZmZmZmZiIgZD0iTTExIDIxQzE2LjUyMjggMjEgMjEgMTYuNTIyOCAyMSAxMUMyMSA1LjQ3NzE1IDE2LjUyMjggMSAxMSAxQzUuNDc3MTUgMSAxIDUuNDc3MTUgMSAxMUMxIDE2LjUyMjggNS40NzcxNSAyMSAxMSAyMVoiLz4KICA8cGF0aCBmaWxsPSIjMGY2ZWMxIiBkPSJNMTEgMTlDMTUuNDE4MyAxOSAxOSAxNS40MTgzIDE5IDExQzE5IDYuNTgxNzIgMTUuNDE4MyAzIDExIDNDNi41ODE3MiAzIDMgNi41ODE3MiAzIDExQzMgMTUuNDE4MyA2LjU4MTcyIDE5IDExIDE5WiIvPgo8L3N2Zz4K"},a=14,u="#ffffff";function l(e){switch(e){case"fast":case"normal":case"slow":case"slow-jams":case"no-traffic":return e;default:return"ignore"}}function c(e){return e.map((function(t,n){var r=String(n);return 0===n&&(r="A"),n===e.length-1&&(r="B"),{position:t,label:{text:r,fontSize:a,color:u},icon:s}}))}var p=n(0),f=function(){function e(e,t){this.map=e,this.settings=t,this.polylines=[],this.markers=[],this.nextPolylinePhase=r,this.nextPointPhase=o}return e.prototype.draw=function(e){this.drawPoints(e.points),this.drawRoutes(e.routes,e.activeRouteId)},e.prototype.clear=function(){this.draw({routes:[],points:[]})},e.prototype.drawPoints=function(e){for(var t=0,n=this.markers;t<n.length;t++){(l=n[t]).destroy()}this.markers=[],this.nextPointPhase=o;for(var r=0;r<e.length;r++){var i=e[r],s=i.position,a=i.label,u=i.icon,l=new mapgl.Marker(this.map,{coordinates:s,icon:u.img,size:u.size,anchor:u.offset,zIndex:this.getNextPointPhase(),label:{text:a.text,fontSize:a.fontSize,color:a.color,anchor:[0,0],zIndex:this.getNextPointPhase()}});this.markers.push(l)}},e.prototype.drawRoutes=function(e,t){for(var n=0,o=this.polylines;n<o.length;n++){o[n].polyline.destroy()}var i;this.polylines=[],this.nextPolylinePhase=r;for(var s=0,a=e;s<a.length;s++){var u=a[s];u.id===t?i=u:this.drawRoute(u,!1)}i&&this.drawRoute(i,!0)},e.prototype.drawRoute=function(e,t){for(var n=e.id,r=e.sections,o=this.getNextPolylinePhase(),i=this.getNextPolylinePhase(),s=0,a=r;s<a.length;s++){var u=a[s],l=Object(p.parse)(u.geometry);if(l){var c=l.coordinates,f=this.settings.lineStyles,d=void 0!==f[u.type]?u.type:"inactive",g=t?d:"inactive",y=f[g],h=y.color,m=y.borderColor,M=y.border2Color,I=new mapgl.Polyline(this.map,{coordinates:c,zIndex:this.getNextPolylinePhase(),zIndex2:i,zIndex3:o,color:h,color2:m,color3:M,width:10.5,width2:21.5,width3:23.1});this.polylines.push({routeId:n,type:g,polyline:I})}}},e.prototype.getNextPolylinePhase=function(){return this.nextPolylinePhase+=1e-6},e.prototype.getNextPointPhase=function(){return this.nextPointPhase+=1e-6},e}(),d=function(e,t){return{color:t[e],hoveredColor:t.hovered,borderColor:t.border,hoveredBorderColor:t.border,border2Color:t.border2,hoveredBorder2Color:t.border2}},g=function(){function e(e,t){this.map=e,this.options=t;var n,r={lineStyles:{normal:d("normal",n=i),fast:d("fast",n),ignore:d("ignore",n),"no-traffic":d("no-traffic",n),slow:d("slow",n),"slow-jams":d("slow-jams",n),pedestrian:d("pedestrian",n),"pedestrian-underground":d("pedestrian-underground",n),inactive:d("inactive",n)}};this.ppnaDrawer=new f(this.map,r)}return e.prototype.clear=function(){this.ppnaDrawer.clear(),this.map.setStyleOptions({traffic:!1})},e.prototype.carRoute=function(e){var t=this,n=e.points;if(n.length<2)throw new Error("At least two points are required");var r={type:"jam",point_a_name:"Source",point_b_name:"Target",locale:"en",points:n.map((function(e,t){return{x:e[0],y:e[1],type:0===t||t===n.length-1?"pedo":"pref"}}))};fetch("https://catalog.api.2gis.ru/carrouting/6.0.0/global?key="+this.options.directionsApiKey,{method:"post",body:JSON.stringify(r)}).then((function(e){if(200!==e.status)throw new Error("HTTP code is "+e.status);return e.json()})).then((function(e){return t.drawCarRoute(e.result||[],n)})).catch((function(e){return console.log(e)}))},e.prototype.drawCarRoute=function(e,t){var n=function(e,t){var n=[];return t.forEach((function(t){var r={id:t.id,sections:[]};t.begin_pedestrian_path&&r.sections.push({type:"pedestrian",geometry:t.begin_pedestrian_path.geometry.selection}),(t.maneuvers||[]).forEach((function(t){var n=t.outcoming_path&&t.outcoming_path.geometry;n&&n.forEach((function(t){r.sections.push({type:"pedestrian"!==e?l(t.color):"pedestrian",geometry:t.selection})}))})),t.end_pedestrian_path&&r.sections.push({type:"pedestrian",geometry:t.end_pedestrian_path.geometry.selection}),n.push(r)})),n}("ppna",e)[0];this.map.setStyleOptions({traffic:!0}),this.ppnaDrawer.draw({routes:[n],points:c(t),activeRouteId:n.id})},e}();"mapgl"in window?mapgl.Directions=g:console.error("Looks like you did not load MapGL API correctly")}])}));

@@ -10,3 +10,2 @@ import { Ppna } from './types/ppnaDrawer';

private settings;
private lineStylesCurves;
private polylines;

@@ -13,0 +12,0 @@ private markers;

@@ -1,2 +0,1 @@

import { LineStylesCurves } from './types/ppnaDrawer';
import { PpnaDefaultColors, PpnaSettings } from './types/styles';

@@ -10,6 +9,1 @@ /**

export declare const getPpnaSettings: (colors: PpnaDefaultColors) => PpnaSettings;
/**
* @hidden
* @internal
*/
export declare function getLineStylesCurves(settings: PpnaSettings): LineStylesCurves;

@@ -1,2 +0,2 @@

import { PpnaRoute, SectionType } from './formatters';
import { PpnaRoute } from './formatters';
/**

@@ -44,13 +44,2 @@ * @hidden

}
/**
* @hidden
* @internal
*/
export declare type LineStylesCurves = {
[type in SectionType]: {
width: Curve;
width2: Curve;
width3: Curve;
};
};
export {};

@@ -18,13 +18,3 @@ import { SectionType } from './formatters';

*/
export interface ZoomDependent<T> {
[zoom: number]: T;
}
/**
* @hidden
* @internal
*/
export interface PpnaSettings {
lineStylesByZoom: ZoomDependent<{
[key in SectionType]: SectionSize;
}>;
lineStyles: {

@@ -35,11 +25,2 @@ [key in SectionType]: SectionStyle;

/**
* @hidden
* @internal
*/
export interface SectionSize {
width: number;
borderWidth: number;
border2Width: number;
}
/**
* Цвет заливки геометрий участка проезда, который идет после совершения маневра.

@@ -46,0 +27,0 @@ *

{
"name": "@2gis/mapgl-directions",
"version": "1.1.0",
"version": "1.1.1",
"description": "Driving directions plugin for Mapgl",

@@ -5,0 +5,0 @@ "main": "dist/directions.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc