diff --git a/htdocs/css/map.css b/htdocs/css/map.css index 70702b96..8d78995e 100644 --- a/htdocs/css/map.css +++ b/htdocs/css/map.css @@ -58,6 +58,17 @@ ul { border-style: solid; } +.openwebrx-map-legend li.square .feature { + display: inline-block; + width: 20px; + height: 20px; + margin-right: 10px; + border-width: 0; + border-style: none; + font-size: 24px; + text-alignment: center; +} + .openwebrx-map-legend select { background-color: #FFF; border-color: #DDD; diff --git a/htdocs/lib/FeatureMarker.js b/htdocs/lib/FeatureMarker.js new file mode 100644 index 00000000..4003923b --- /dev/null +++ b/htdocs/lib/FeatureMarker.js @@ -0,0 +1,58 @@ +function FeatureMarker() {} + +FeatureMarker.prototype = new google.maps.OverlayView(); + +FeatureMarker.prototype.draw = function() { + var div = this.div; + if (!div) return; + + div.style.color = this.color? this.color : '#000000'; + div.innerHTML = this.symbol? this.symbol : '●'; + + var point = this.getProjection().fromLatLngToDivPixel(this.position); + if (point) { + div.style.left = point.x - this.symWidth/2 + 'px'; + div.style.top = point.y - this.symHeight/2 + 'px'; + } +}; + +FeatureMarker.prototype.setOptions = function(options) { + google.maps.OverlayView.prototype.setOptions.apply(this, arguments); + this.draw(); +}; + +FeatureMarker.prototype.onAdd = function() { + var div = this.div = document.createElement('div'); + + // Marker size + this.symWidth = 16; + this.symHeight = 16; + + div.style.position = 'absolute'; + div.style.cursor = 'pointer'; + div.style.width = this.symWidth + 'px'; + div.style.height = this.symHeight + 'px'; + div.style.textAlign = 'center'; + div.style.fontSize = this.symHeight + 'px'; + div.style.lineHeight = this.symHeight + 'px'; + + var self = this; + google.maps.event.addDomListener(div, "click", function(event) { + event.stopPropagation(); + google.maps.event.trigger(self, "click", event); + }); + + var panes = this.getPanes(); + panes.overlayImage.appendChild(div); +}; + +FeatureMarker.prototype.remove = function() { + if (this.div) { + this.div.parentNode.removeChild(this.div); + this.div = null; + } +}; + +FeatureMarker.prototype.getAnchorPoint = function() { + return new google.maps.Point(0, -this.symHeight/2); +}; diff --git a/htdocs/map.html b/htdocs/map.html index f7644fcf..ee032a3e 100644 --- a/htdocs/map.html +++ b/htdocs/map.html @@ -22,6 +22,13 @@
+