diff --git a/public_html/markers.js b/public_html/markers.js index 2dae794..508be20 100755 --- a/public_html/markers.js +++ b/public_html/markers.js @@ -61,31 +61,57 @@ var _heavy_svg = var MarkerIcons = { generic : { scale : 0.4, + size : [64, 64], anchor : [32, 32], path : _generic_plane_svg }, light : { scale : 0.4, + size : [64, 64], anchor : [32, 25], path : _beechcraft_svg }, medium : { scale : 0.4, + size : [64, 64], anchor : [32, 32], path : _generic_plane_svg }, heavy : { scale : 0.6, + size : [64, 64], anchor : [32, 32], path : _heavy_svg }, rotorcraft : { scale : 0.5, + size : [64, 64], anchor : [22, 32], path : _rotorcraft_svg } }; + +function svgPathToSvg(path, size, stroke, width, fill) { + var svg = ''; + svg += ' " + svgKey); + + this.markerIcon = new ol.style.Icon({ + anchor: MarkerIcons[type].anchor, + anchorXUnits: 'pixels', + anchorYUnits: 'pixels', + scale: MarkerIcons[type].scale, + imgSize: MarkerIcons[type].size, + src: svgPathToURI(MarkerIcons[type].path, MarkerIcons[type].size, outline, weight, col), + rotation: rotation * Math.PI / 180.0, + opacity: opacity + }); + + this.markerStyleKey = styleKey; + this.markerSvgKey = svgKey; + this.markerStyle = new ol.style.Style({ + image: this.markerIcon + }); + + if (this.marker !== null) { + this.marker.setStyle(this.markerStyle); + } + } + + if (this.markerStyleKey != styleKey) { + console.log(this.icao + " new rotation"); + this.markerIcon.setRotation(rotation * Math.PI / 180.0); + this.markerIcon.setOpacity(opacity); + this.markerStyleKey = styleKey; } return true; @@ -373,13 +397,14 @@ PlaneObject.prototype.updateMarker = function(moved) { return; } + this.updateIcon(); if (this.marker) { if (moved) { this.marker.setGeometry(new ol.geom.Point(ol.proj.fromLonLat(this.position))); } } else { this.marker = new ol.Feature(new ol.geom.Point(ol.proj.fromLonLat(this.position))); - this.updateIcon(); + this.marker.setStyle(this.markerStyle); PlaneIconFeatures.push(this.marker); /* FIXME @@ -389,7 +414,6 @@ PlaneObject.prototype.updateMarker = function(moved) { */ } - this.updateIcon(); /* // Setting the marker title