@@ -118,17 +118,17 @@ console.log("CONNECT TO",location.pathname + 'socket');
118118var handleData = function ( data ) {
119119 if ( Array . isArray ( data ) ) {
120120 // console.log("ARRAY:",data.length);
121- for ( var prop in data ) {
122- if ( data [ prop ] . command ) { doCommand ( data [ prop ] . command ) ; delete data [ prop ] . command ; }
123- if ( data [ prop ] . hasOwnProperty ( "name" ) ) {
124- setMarker ( data [ prop ] ) ;
125- // bnds.extend(markers[data[ prop] .name].getLatLng());
126- }
127- else if ( data [ prop ] . hasOwnProperty ( "filename" ) && data [ prop ] . filename === "doc.kml" ) {
128- data = { command :{ map :{ overlay :"KML" , kml :data [ prop ] . payload } } } ;
121+ for ( var prop of data ) {
122+ if ( prop . command ) { doCommand ( prop . command ) ; delete prop . command ; }
123+ if ( prop . hasOwnProperty ( "name" ) ) {
124+ setMarker ( prop ) ;
125+ // bnds.extend(markers[prop.name].getLatLng());
126+ }
127+ else if ( prop . hasOwnProperty ( "filename" ) && prop . filename === "doc.kml" ) {
128+ data = { command :{ map :{ overlay :"KML" , kml :prop . payload } } } ;
129129 doCommand ( data . command ) ; return ;
130130 }
131- else { console . log ( "SKIP array item" , data [ prop ] ) ; }
131+ else { console . log ( "SKIP array item" , prop ) ; }
132132 }
133133 }
134134 else {
@@ -329,7 +329,7 @@ var errRing;
329329function onLocationFound ( e ) {
330330 if ( followState === true ) { map . panTo ( e . latlng ) ; }
331331 if ( followMode . icon ) {
332- var self = { name :followMode . name || "self" , lat :e . latlng . lat , lon :e . latlng . lng , hdg :e . heading , speed :( e . speed * 1 ?? undefined ) , layer :followMode . layer , icon :followMode . icon , iconColor :followMode . iconColor ?? "#910000" } ;
332+ var self = { name :followMode . name || "self" , lat :e . latlng . lat , lon :e . latlng . lng , hdg :isNaN ( e ? .heading * 1 ) ? undefined : e ?. heading * 1 , speed :isNaN ( e ? .speed * 1 ) ? undefined : e ?. speed * 1 , layer :followMode . layer , icon :followMode . icon , iconColor :followMode . iconColor ?? "#910000" } ;
333333 setMarker ( self ) ;
334334 }
335335 if ( e . heading !== null ) { map . setBearing ( e . heading ) ; }
@@ -344,7 +344,7 @@ function onLocationFound(e) {
344344 // L.polygon([ e.latlng, lla ], {color:"00ffff", weight:3, opacity:0.5, clickable:false}).addTo(map);
345345 // }
346346 }
347- ws . send ( JSON . stringify ( { action :"point" , lat :e . latlng . lat . toFixed ( 5 ) , lon :e . latlng . lng . toFixed ( 5 ) , point :"self" , hdg :e . heading , speed :( e . speed * 1 ?? undefined ) } ) ) ;
347+ ws . send ( JSON . stringify ( { action :"point" , lat :e . latlng . lat . toFixed ( 5 ) , lon :e . latlng . lng . toFixed ( 5 ) , point :"self" , hdg :isNaN ( e ? .heading * 1 ) ? undefined : e ?. heading * 1 , speed :isNaN ( e ? .speed * 1 ) ? undefined : e ?. speed * 1 } ) ) ;
348348}
349349
350350function onLocationError ( e ) { console . log ( e . message ) ; }
@@ -2197,9 +2197,9 @@ function setMarker(data) {
21972197 marker . on ( 'dragend' , function ( e ) {
21982198 var l = marker . getLatLng ( ) . toString ( ) . replace ( 'LatLng(' , 'lat, lon : ' ) . replace ( ')' , '' )
21992199 marker . setPopupContent ( marker . getPopup ( ) . getContent ( ) . split ( "lat, lon" ) [ 0 ] + l ) ;
2200- var b = marker . getPopup ( ) . getContent ( ) . split ( "heading : " ) ;
2201- if ( b . length === 2 ) { b = parseFloat ( b [ 1 ] . split ( "<br" ) [ 0 ] ) ; }
2202- else { b = undefined ; }
2200+ // var b = marker.getPopup().getContent().split("heading : ");
2201+ // if (b.length === 2) { b = parseFloat(b[1].split("<br")[0]); }
2202+ // else { b = undefined; }
22032203
22042204 var fb = allData [ marker . name ] ;
22052205 fb . action = "move" ;
@@ -2306,7 +2306,7 @@ function setMarker(data) {
23062306 delete data . popped ;
23072307 }
23082308 // If .label then use that rather than name tooltip
2309- if ( data . label ) {
2309+ if ( data . hasOwnProperty ( " label" ) ) {
23102310 if ( typeof data . label === "boolean" && data . label === true ) {
23112311 marker . bindTooltip ( data [ "name" ] , data . tooltipOptions || { permanent :true , direction :"right" , offset :labelOffset } ) ;
23122312 }
@@ -2317,7 +2317,7 @@ function setMarker(data) {
23172317 delete data . label ;
23182318 }
23192319 // otherwise check for .tooltip then use that rather than name tooltip
2320- else if ( data . tooltip ) {
2320+ else if ( data . hasOwnProperty ( " tooltip" ) ) {
23212321 if ( typeof data . tooltip === "string" && data . tooltip . length > 0 ) {
23222322 marker . bindTooltip ( data . tooltip , data . tooltipOptions || { direction :"bottom" , offset :[ 0 , 4 ] } ) ;
23232323 delete marker . options . title ;
0 commit comments