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

@2gis/mapgl-directions

Package Overview
Dependencies
Maintainers
3
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.2.0 to 1.3.0

2

dist/directions.js

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

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.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 r(e){return e.join(" ")}function n(e){return e.map(r).join(", ")}function o(e){return e.map(n).map(i).join(", ")}function i(e){return"("+e+")"}switch(t.type){case"Point":return"POINT ("+r(t.coordinates)+")";case"LineString":return"LINESTRING ("+n(t.coordinates)+")";case"Polygon":return"POLYGON ("+o(t.coordinates)+")";case"MultiPoint":return"MULTIPOINT ("+n(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 r=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,n=new RegExp("^"+r.source+"(\\s"+r.source+"){1,}");function o(e){var t,r=e.split(";"),o=r.pop(),i=(r.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,r=[],o=[r],i=r;e=a(/^(\()/)||a(/^(\))/)||a(/^(,)/)||a(n);){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:r}function p(){for(var e,t,r=[];t=a(n)||a(/^(,)/);)","===t?(r.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?(r.push(e),r.length?r:null):null}function c(){return function(){if(!a(/^(point(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var e=p();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=p();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=c();)t.push(e),u(),a(/^(,)/),u();return a(/^(\))/)?{type:"GeometryCollection",geometries:t}:null}()}return(t=c())&&i.match(/\d+/)&&(t.crs={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+i}}),t}},function(e,t,r){"use strict";r.r(t),r.d(t,"Directions",(function(){return g}));var n=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 p(e){return e.map((function(t,r){var n=String(r);return 0===r&&(n="A"),r===e.length-1&&(n="B"),{position:t,label:{text:n,fontSize:a,color:u},icon:s}}))}var c=r(0),f=function(){function e(e,t){this.map=e,this.settings=t,this.polylines=[],this.markers=[],this.nextPolylinePhase=n,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,r=this.markers;t<r.length;t++){(l=r[t]).destroy()}this.markers=[],this.nextPointPhase=o;for(var n=0;n<e.length;n++){var i=e[n],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 r=0,o=this.polylines;r<o.length;r++){o[r].polyline.destroy()}var i;this.polylines=[],this.nextPolylinePhase=n;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 r=e.id,n=e.sections,o=this.getNextPolylinePhase(),i=this.getNextPolylinePhase(),s=0,a=n;s<a.length;s++){var u=a[s],l=Object(c.parse)(u.geometry);if(l){var p=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:p,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:r,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 r,n={lineStyles:{normal:d("normal",r=i),fast:d("fast",r),ignore:d("ignore",r),"no-traffic":d("no-traffic",r),slow:d("slow",r),"slow-jams":d("slow-jams",r),pedestrian:d("pedestrian",r),"pedestrian-underground":d("pedestrian-underground",r),inactive:d("inactive",r)}};this.ppnaDrawer=new f(this.map,n)}return e.prototype.clear=function(){this.ppnaDrawer.clear(),this.map.setStyleOptions({traffic:!1})},e.prototype.carRoute=function(e){var t=this,r=e.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(e,t){return{x:e[0],y:e[1],type:0===t||t===r.length-1?"pedo":"pref"}}))};return fetch("https://catalog.api.2gis.ru/carrouting/6.0.0/global?key="+this.options.directionsApiKey,{method:"post",body:JSON.stringify(n)}).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||[],r)}))},e.prototype.drawCarRoute=function(e,t){var r=function(e,t){var r=[];return t.forEach((function(t){var n={id:t.id,sections:[]};t.begin_pedestrian_path&&n.sections.push({type:"pedestrian",geometry:t.begin_pedestrian_path.geometry.selection}),(t.maneuvers||[]).forEach((function(t){var r=t.outcoming_path&&t.outcoming_path.geometry;r&&r.forEach((function(t){n.sections.push({type:"pedestrian"!==e?l(t.color):"pedestrian",geometry:t.selection})}))})),t.end_pedestrian_path&&n.sections.push({type:"pedestrian",geometry:t.end_pedestrian_path.geometry.selection}),r.push(n)})),r}("ppna",e)[0];this.map.setStyleOptions({traffic:!0}),this.ppnaDrawer.draw({routes:[r],points:p(t),activeRouteId:r.id})},e}();"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 p(){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 c(){return function(){if(!a(/^(point(\sz)?)/i))return null;if(u(),!a(/^(\()/))return null;var e=p();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=p();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=c();)t.push(e),u(),a(/^(,)/),u();return a(/^(\))/)?{type:"GeometryCollection",geometries:t}:null}()}return(t=c())&&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 p(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 c=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(),haloRadius:0,haloColor:"#ffffff",letterSpacing:0,lineHeight:1.2,minZoom:NaN,maxZoom:NaN}});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(c.parse)(u.geometry);if(l){var p=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:p,zIndex:this.getNextPolylinePhase(),zIndex2:i,zIndex3:o,color:h,color2:m,color3:M,width:10.5,width2:21.5,width3:23.1,interactive:!0,maxZoom:NaN,minZoom:NaN});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=e.points;return this.findAndDrawRoute({type:"jam",points:t})},e.prototype.pedestrianRoute=function(e){var t=e.points;return this.findAndDrawRoute({type:"pedestrian",points:t})},e.prototype.findAndDrawRoute=function(e){var t=this,n=e.points,r=e.type;if(n.length<2)throw new Error("At least two points are required");var o={type:r,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"}}))};return fetch("https://catalog.api.2gis.ru/carrouting/6.0.0/global?key="+this.options.directionsApiKey,{method:"post",body:JSON.stringify(o)}).then((function(e){if(200!==e.status)throw new Error("HTTP code is "+e.status);return e.json()})).then((function(n){return t.drawRoute(n.result||[],e.points)}))},e.prototype.drawRoute=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:p(t),activeRouteId:n.id})},e}();"mapgl"in window?mapgl.Directions=g:console.error("Looks like you did not load MapGL API correctly")}])}));

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

{"typescript":{"Directions":{"documentation":{"contents":["<p>A class that provides driving direction functionality.</p>\n"],"contentsRaw":"A class that provides driving direction functionality.","metadata":{}},"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"class","name":"Directions","methods":[{"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":true,"isRest":false,"isStatic":false},"kind":"method","name":"carRoute","signatures":[{"documentation":{"contents":["<p>Finds and draws an optimal car route.</p>\n"],"contentsRaw":"Finds and draws an optimal car route.","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"carRoute","parameters":[{"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"options","type":"CarRouteOptions"}],"returnType":"Promise<void>","type":"(options: CarRouteOptions) => Promise<void>"}]},{"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":true,"isRest":false,"isStatic":false},"kind":"method","name":"clear","signatures":[{"documentation":{"contents":["<p>Clears the map from any previously drawn routes.</p>\n"],"contentsRaw":"Clears the map from any previously drawn routes.","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"clear","parameters":[],"returnType":"void","type":"() => void"}]}],"properties":[],"accessors":[],"constructorType":{"documentation":{"contents":["<p>Example:</p>\n<pre><code class=\"language-js\">const directions = new mapgl.Directions(map, {\n directionsApiKey: &#39;Your Directions API access key&#39;,\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});</code></pre>\n"],"contentsRaw":"Example:\n```js\nconst directions = new mapgl.Directions(map, {\n directionsApiKey: 'Your Directions API access key',\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});\n```","metadata":{}},"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"constructor","name":"constructor","signatures":[{"documentation":{"contents":["<p>Example:</p>\n<pre><code class=\"language-js\">const directions = new mapgl.Directions(map, {\n directionsApiKey: &#39;Your Directions API access key&#39;,\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});</code></pre>\n"],"contentsRaw":"Example:\n```js\nconst directions = new mapgl.Directions(map, {\n directionsApiKey: 'Your Directions API access key',\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});\n```","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"new Directions","parameters":[{"documentation":{"contents":["<p>The map instance.</p>\n"],"contentsRaw":"The map instance.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"map","type":"mapgl.Map"},{"documentation":{"contents":["<p>Directions initialization options.</p>\n"],"contentsRaw":"Directions initialization options.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"options","type":"DirectionsOptions"}],"returnType":"Directions","type":"(map: mapgl.Map, options: DirectionsOptions) => Directions"}]}},"DirectionsOptions":{"documentation":{"contents":["<p>Directions initialization options.</p>\n"],"contentsRaw":"Directions initialization options.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"DirectionsOptions","methods":[],"properties":[{"documentation":{"contents":["<p>Directions API access key.</p>\n"],"contentsRaw":"Directions API access key.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"directionsApiKey","type":"string"}]},"CarRouteOptions":{"documentation":{"contents":["<p>Car route options.</p>\n"],"contentsRaw":"Car route options.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"CarRouteOptions","methods":[],"properties":[{"documentation":{"contents":["<p>Array of geographical points [longitude, latitude].</p>\n<p>You can set up to 10 points.</p>\n"],"contentsRaw":"Array of geographical points [longitude, latitude].\n\nYou can set up to 10 points.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"points","type":"Point[]"}]},"Point":{"documentation":{"contents":["<p>A geographical point [longitude, latitude].</p>\n"],"contentsRaw":"A geographical point [longitude, latitude].","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"type alias","name":"Point","type":"[number, number] | number[]"}}}
{"typescript":{"Directions":{"documentation":{"contents":["<p>A class that provides driving direction functionality.</p>\n"],"contentsRaw":"A class that provides driving direction functionality.","metadata":{}},"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"class","name":"Directions","methods":[{"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":true,"isRest":false,"isStatic":false},"kind":"method","name":"carRoute","signatures":[{"documentation":{"contents":["<p>Finds and draws an optimal car route.</p>\n"],"contentsRaw":"Finds and draws an optimal car route.","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"carRoute","parameters":[{"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"options","type":"CarRouteOptions"}],"returnType":"Promise<void>","type":"(options: CarRouteOptions) => Promise<void>"}]},{"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":true,"isRest":false,"isStatic":false},"kind":"method","name":"clear","signatures":[{"documentation":{"contents":["<p>Clears the map from any previously drawn routes.</p>\n"],"contentsRaw":"Clears the map from any previously drawn routes.","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"clear","parameters":[],"returnType":"void","type":"() => void"}]},{"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":true,"isRest":false,"isStatic":false},"kind":"method","name":"pedestrianRoute","signatures":[{"documentation":{"contents":["<p>Finds and draws an optimal pedestrian route.</p>\n"],"contentsRaw":"Finds and draws an optimal pedestrian route.","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"pedestrianRoute","parameters":[{"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"options","type":"PedestrianRouteOptions"}],"returnType":"Promise<void>","type":"(options: PedestrianRouteOptions) => Promise<void>"}]}],"properties":[],"accessors":[],"constructorType":{"documentation":{"contents":["<p>Example:</p>\n<pre><code class=\"language-js\">const directions = new mapgl.Directions(map, {\n directionsApiKey: &#39;Your Directions API access key&#39;,\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});</code></pre>\n"],"contentsRaw":"Example:\n```js\nconst directions = new mapgl.Directions(map, {\n directionsApiKey: 'Your Directions API access key',\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});\n```","metadata":{}},"fileName":"src/directions.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"constructor","name":"constructor","signatures":[{"documentation":{"contents":["<p>Example:</p>\n<pre><code class=\"language-js\">const directions = new mapgl.Directions(map, {\n directionsApiKey: &#39;Your Directions API access key&#39;,\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});</code></pre>\n"],"contentsRaw":"Example:\n```js\nconst directions = new mapgl.Directions(map, {\n directionsApiKey: 'Your Directions API access key',\n});\n\ndirections.carRoute({\n points: [\n [55.2772379, 25.2377810],\n [55.2986956, 25.2576546],\n ],\n});\n```","metadata":{}},"fileName":"src/directions.ts","kind":"signature","name":"new Directions","parameters":[{"documentation":{"contents":["<p>The map instance.</p>\n"],"contentsRaw":"The map instance.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"map","type":"mapgl.Map"},{"documentation":{"contents":["<p>Directions initialization options.</p>\n"],"contentsRaw":"Directions initialization options.","metadata":{}},"flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"parameter","name":"options","type":"DirectionsOptions"}],"returnType":"Directions","type":"(map: mapgl.Map, options: DirectionsOptions) => Directions"}]}},"DirectionsOptions":{"documentation":{"contents":["<p>Directions initialization options.</p>\n"],"contentsRaw":"Directions initialization options.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"DirectionsOptions","methods":[],"properties":[{"documentation":{"contents":["<p>Directions API access key.</p>\n"],"contentsRaw":"Directions API access key.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"directionsApiKey","type":"string"}]},"CarRouteOptions":{"documentation":{"contents":["<p>Car route method options.</p>\n"],"contentsRaw":"Car route method options.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"CarRouteOptions","methods":[],"properties":[{"documentation":{"contents":["<p>Array of geographical points [longitude, latitude].</p>\n<p>You can set up to 10 points.</p>\n"],"contentsRaw":"Array of geographical points [longitude, latitude].\n\nYou can set up to 10 points.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"points","type":"Point[]"}]},"PedestrianRouteOptions":{"documentation":{"contents":["<p>Pedestrian route method options.</p>\n"],"contentsRaw":"Pedestrian route method options.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"interface","name":"PedestrianRouteOptions","methods":[],"properties":[{"documentation":{"contents":["<p>Array of geographical points [longitude, latitude].</p>\n<p>You can set up to 10 points.</p>\n"],"contentsRaw":"Array of geographical points [longitude, latitude].\n\nYou can set up to 10 points.","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"property","name":"points","type":"Point[]"}]},"Point":{"documentation":{"contents":["<p>A geographical point [longitude, latitude].</p>\n"],"contentsRaw":"A geographical point [longitude, latitude].","metadata":{}},"fileName":"src/types/index.ts","flags":{"isExported":true,"isExternal":false,"isOptional":false,"isPrivate":false,"isProtected":false,"isPublic":false,"isRest":false,"isStatic":false},"kind":"type alias","name":"Point","type":"[number, number] | number[]"}}}

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

import { CarRouteOptions, DirectionsOptions } from './types';
import { DirectionsOptions, CarRouteOptions, PedestrianRouteOptions } from './types';
/**

@@ -36,6 +36,15 @@ * A class that provides driving direction functionality.

/**
* Finds and draws an optimal pedestrian route.
*/
pedestrianRoute(options: PedestrianRouteOptions): Promise<void>;
/**
* @hidden
* @internal
*/
private drawCarRoute;
private findAndDrawRoute;
/**
* @hidden
* @internal
*/
private drawRoute;
}
import { Directions } from './directions';
export { Directions };
export { DirectionsOptions, CarRouteOptions } from './types';
export { DirectionsOptions, CarRouteOptions, PedestrianRouteOptions } from './types';

@@ -15,3 +15,3 @@ /**

/**
* Car route options.
* Car route method options.
*/

@@ -26,1 +26,20 @@ export interface CarRouteOptions {

}
/**
* Pedestrian route method options.
*/
export interface PedestrianRouteOptions {
/**
* Array of geographical points [longitude, latitude].
*
* You can set up to 10 points.
*/
points: Point[];
}
/**
* @hidden
* @internal
*/
export interface PpnaRouteOptions {
type: 'jam' | 'pedestrian';
points: Point[];
}
/**
* @hidden
* @internal
*/
export declare type PpnaQueryType = 'jam' | 'statistic' | 'shortest' | 'pedestrian';
/**
* https://confluence.2gis.ru/display/TRAFFIC/API+CarRouting+v3%2C+v4#APICarRoutingv3,v4-type

@@ -8,3 +13,3 @@ *

export interface PpnaQuery {
type: 'jam' | 'statistic' | 'shortest' | 'pedestrian';
type: PpnaQueryType;
locale: string;

@@ -11,0 +16,0 @@ point_a_name: string;

{
"name": "@2gis/mapgl-directions",
"version": "1.2.0",
"version": "1.3.0",
"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