From 4210a8088ed9f590be1837f99e56f955a6ea8ab5 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Wed, 16 Feb 2022 08:17:15 +0100 Subject: [PATCH] [QRB Calculator] Added local copy of js. Some tweaks and popup to the map. --- application/views/interface_assets/footer.php | 18 ++++++++---------- assets/js/leaflet/leaflet.geodesic.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 assets/js/leaflet/leaflet.geodesic.js diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index e4f0c40b..90839706 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -6,7 +6,7 @@ - + @@ -474,7 +474,7 @@ function calculateQrb(form) { result += 'the bearing is ' + html['bearing'] + '.'; $(".qrbResult").html(result); - newpath(html['latlng1'], html['latlng2']); + newpath(html['latlng1'], html['latlng2'], locator1, locator2); } }); } else { @@ -490,7 +490,7 @@ function validateLocator(locator) { return true; } -function newpath(locator1, locator2) { +function newpath(latlng1, latlng2, locator1, locator2) { // If map is already initialized var container = L.DomUtil.get('mapqrb'); @@ -512,20 +512,18 @@ function newpath(locator1, locator2) { }); map.addLayer(osm); - var marker = L.marker([locator1[0], locator1[1]], {icon: redIcon}); - map.addLayer(marker); - var marker2 = L.marker([locator2[0], locator2[1]], {icon: redIcon}); - map.addLayer(marker2); + var marker = L.marker([latlng1[0], latlng1[1]], {closeOnClick: false, autoClose: false}).addTo(map).bindPopup(locator1); + var marker2 = L.marker([latlng2[0], latlng2[1]], {closeOnClick: false, autoClose: false}).addTo(map).bindPopup(locator2); const multiplelines = []; multiplelines.push( - new L.LatLng(locator1[0], locator1[1]), - new L.LatLng(locator2[0], locator2[1]) + new L.LatLng(latlng1[0], latlng1[1]), + new L.LatLng(latlng2[0], latlng2[1]) ) const geodesic = L.geodesic(multiplelines, { - weight: 1, + weight: 3, opacity: 1, color: 'red', wrap: false, diff --git a/assets/js/leaflet/leaflet.geodesic.js b/assets/js/leaflet/leaflet.geodesic.js new file mode 100644 index 00000000..6455fab1 --- /dev/null +++ b/assets/js/leaflet/leaflet.geodesic.js @@ -0,0 +1,16 @@ +/*! Leaflet.Geodesic 2.6.1 - (c) Henry Thasler - https://github.com/henrythasler/Leaflet.Geodesic */ +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],n):n(((t="undefined"!=typeof globalThis?globalThis:t||self).L=t.L||{},t.L.geodesic={}),t.L)}(this,(function(t,n){"use strict";function e(t){if(t&&t.__esModule)return t;var n=Object.create(null);return t&&Object.keys(t).forEach((function(e){if("default"!==e){var i=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,i.get?i:{enumerable:!0,get:function(){return t[e]}})}})),n.default=t,Object.freeze(n)}var i=e(n),a=function(t,n){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},a(t,n)}; +/*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */function o(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}var s=function(){return s=Object.assign||function(t){for(var n,e=1,i=arguments.length;el&&++x=i)throw new EvalError("Direct vincenty formula failed to converge after ".concat(i," iterations \n (start=").concat(t.lat,"/").concat(t.lng,"; bearing=").concat(n,"; distance=").concat(e,")"));var j=L*P-M*R*f,G=Math.atan2(L*R+M*P*f,(1-u)*Math.sqrt(v*v+j*j)),N=u/16*w*(4+u*(4-3*w)),_=o+(Math.atan2(P*g,M*R-L*P*f)-(1-N)*u*v*(S+N*P*(E+N*R*(2*E*E-1)))),T=Math.atan2(v,-j);return{lat:this.toDegrees(G),lng:this.toDegrees(_),bearing:this.wrap360(this.toDegrees(T))}},t.prototype.inverse=function(t,n,e,a){void 0===e&&(e=100),void 0===a&&(a=!0);var o=t,s=n,r=this.toRadians(o.lat),l=this.toRadians(o.lng),h=this.toRadians(s.lat),c=this.toRadians(s.lng),p=Math.PI,u=Number.EPSILON,g=this.ellipsoid,f=g.a,d=g.b,M=g.f,L=c-l,y=(1-M)*Math.tan(r),v=1/Math.sqrt(1+y*y),w=y*v,b=(1-M)*Math.tan(h),m=1/Math.sqrt(1+b*b),O=b*m,S=Math.abs(L)>p/2||Math.abs(h-r)>p/2,P=L,R=null,E=null,D=S?p:0,x=0,j=S?-1:1,G=null,N=1,_=null,T=1,q=null,A=null,C=0;do{if(G=m*(R=Math.sin(P))*(m*R)+(v*O-w*m*(E=Math.cos(P)))*(v*O-w*m*E),Math.abs(G)p)throw new EvalError("λ > π")}while(Math.abs(P-A)>1e-12&&++C=e){if(a)return this.inverse(t,new i.LatLng(n.lat,n.lng-.01),e,a);throw new EvalError("Inverse vincenty formula failed to converge after ".concat(e," iterations \n (start=").concat(t.lat,"/").concat(t.lng,"; dest=").concat(n.lat,"/").concat(n.lng,")"))}var I=T*(f*f-d*d)/(d*d),k=I/1024*(256+I*(I*(74-47*I)-128)),B=d*(1+I/16384*(4096+I*(I*(320-175*I)-768)))*(D-k*x*(N+k/4*(j*(2*N*N-1)-k/6*N*(4*x*x-3)*(4*N*N-3)))),J=Math.abs(G)0?y:2*g-y),b=(Math.sin(l-s)>0?2*g-v:v)-c;if(0===Math.sin(w)&&0===Math.sin(b))return null;if(Math.sin(w)*Math.sin(b)<0)return null;var m=-Math.cos(w)*Math.cos(b)+Math.sin(w)*Math.sin(b)*Math.cos(d),O=Math.atan2(Math.sin(d)*Math.sin(w)*Math.sin(b),Math.cos(b)+Math.cos(w)*m),S=Math.asin(Math.min(Math.max(Math.sin(o)*Math.cos(O)+Math.cos(o)*Math.sin(O)*Math.cos(h),-1),1)),P=s+Math.atan2(Math.sin(h)*Math.sin(O)*Math.cos(o),Math.cos(O)-Math.sin(o)*Math.sin(S));return new i.LatLng(this.toDegrees(S),this.toDegrees(P))},t.prototype.midpoint=function(t,n){var e=this.toRadians(t.lat),a=this.toRadians(t.lng),o=this.toRadians(n.lat),s=this.toRadians(n.lng-t.lng),r=Math.cos(e),l=0,h=Math.sin(e),c={x:r+Math.cos(o)*Math.cos(s),y:l+Math.cos(o)*Math.sin(s),z:h+Math.sin(o)},p=Math.atan2(c.z,Math.sqrt(c.x*c.x+c.y*c.y)),u=a+Math.atan2(c.y,c.x);return new i.LatLng(this.toDegrees(p),this.toDegrees(u))},t}(),h=function(){function t(t){this.geodesic=new l,this.steps=t&&void 0!==t.steps?t.steps:3}return t.prototype.recursiveMidpoint=function(t,n,e){var i=[t,n],a=this.geodesic.midpoint(t,n);return e>0?(i.splice.apply(i,r([0,1],this.recursiveMidpoint(t,a,e-1),!1)),i.splice.apply(i,r([i.length-2,2],this.recursiveMidpoint(a,n,e-1),!1))):i.splice(1,0,a),i},t.prototype.line=function(t,n){return this.recursiveMidpoint(t,n,Math.min(8,this.steps))},t.prototype.multiLineString=function(t){for(var n=[],e=0,i=t;e180?s.lng=s.lng-360:s.lng-o.lng<-180&&(s.lng=s.lng+360);var r=[[new i.LatLng(o.lat,this.geodesic.wrap(o.lng,180)),new i.LatLng(s.lat,this.geodesic.wrap(s.lng,180))]];if(o.lng>=-180&&o.lng<=180){if(s.lng<-180){var l=this.geodesic.inverse(o,s).initialBearing;(h=this.geodesic.intersection(o,l,e.point,e.bearing))&&(r=[[o,h],[new i.LatLng(h.lat,h.lng+360),new i.LatLng(s.lat,s.lng+360)]])}else if(s.lng>180){l=this.geodesic.inverse(o,s).initialBearing;(h=this.geodesic.intersection(o,l,a.point,a.bearing))&&(r=[[o,h],[new i.LatLng(h.lat,h.lng-360),new i.LatLng(s.lat,s.lng-360)]])}}else if(s.lng>=-180&&s.lng<=180)if(o.lng<-180){l=this.geodesic.inverse(o,s).initialBearing;(h=this.geodesic.intersection(o,l,e.point,e.bearing))&&(r=[[new i.LatLng(o.lat,o.lng+360),new i.LatLng(h.lat,h.lng+360)],[h,s]])}else if(o.lng>180){var h;l=this.geodesic.inverse(o,s).initialBearing;(h=this.geodesic.intersection(o,l,e.point,e.bearing))&&(r=[[new i.LatLng(o.lat,o.lng-360),new i.LatLng(h.lat,h.lng-360)],[h,s]])}return r},t.prototype.splitMultiLineString=function(t){for(var n=[],e=0,i=t;e1&&(n.push(o),o=r[1])}n.push(o)}else n.push(a)}return n},t.prototype.wrapMultiLineString=function(t){for(var n=[],e=0,a=t;e