Let circles be clickable, and better ellipses.
This commit is contained in:
parent
2e35345be1
commit
f9a0e7bb28
@ -1,5 +1,6 @@
|
|||||||
### Change Log for Node-RED Worldmap
|
### Change Log for Node-RED Worldmap
|
||||||
|
|
||||||
|
- v2.0.3-beta - Let circles have popups. Better drawing of ellipses
|
||||||
- v2.0.2-beta - Let lines and areas also have popups
|
- v2.0.2-beta - Let lines and areas also have popups
|
||||||
- v2.0.1-beta - Add optional graticule.
|
- v2.0.1-beta - Add optional graticule.
|
||||||
- v2.0.0-beta - Move to leaflet 1.4.x plus all plugins updated
|
- v2.0.0-beta - Move to leaflet 1.4.x plus all plugins updated
|
||||||
|
12
README.md
12
README.md
@ -9,6 +9,7 @@ map web page for plotting "things" on.
|
|||||||
|
|
||||||
### Updates
|
### Updates
|
||||||
|
|
||||||
|
- v2.0.3-beta - Let circles have popups. Better drawing of ellipses
|
||||||
- v2.0.2-beta - Let lines and areas also have popups
|
- v2.0.2-beta - Let lines and areas also have popups
|
||||||
- v2.0.1-beta - Add optional graticule
|
- v2.0.1-beta - Add optional graticule
|
||||||
- v2.0.0-beta - Move to leaflet 1.4.x plus all plugins updated
|
- v2.0.0-beta - Move to leaflet 1.4.x plus all plugins updated
|
||||||
@ -200,7 +201,7 @@ then rather than draw a point and icon it draws the polygon. Likewise if it cont
|
|||||||
- **clickable** : boolean - set to true to allow click to show popup.
|
- **clickable** : boolean - set to true to allow click to show popup.
|
||||||
- **popup** : html string to display in popup (as well as name).
|
- **popup** : html string to display in popup (as well as name).
|
||||||
|
|
||||||
### Circles
|
### Circles and Ellipses
|
||||||
|
|
||||||
If the msg.payload contains a **radius** property, as well as name, lat and lon, then rather
|
If the msg.payload contains a **radius** property, as well as name, lat and lon, then rather
|
||||||
than draw a point it will draw a circle. The *radius* property is specified in meters.
|
than draw a point it will draw a circle. The *radius* property is specified in meters.
|
||||||
@ -209,8 +210,11 @@ than draw a point it will draw a circle. The *radius* property is specified in m
|
|||||||
|
|
||||||
As per Areas and Lines you may also specify *color*, *fillColor*, and *layer*.
|
As per Areas and Lines you may also specify *color*, *fillColor*, and *layer*.
|
||||||
|
|
||||||
If the payload contains a **sdlat** and **sdlon** property instead of *radius* an ellipse will be drawn. The sdlat and sdlon propertys specify the semi-axes of the ellipse.
|
If the **radius** property is an array of two numbers, these specify the minor and major radii
|
||||||
These are specified in the Latitude/Longitude format.
|
of an ellipse, in meters. A **tilt** property can also be applied to rotate the ellipse by
|
||||||
|
a number of degrees.
|
||||||
|
|
||||||
|
msg.payload = { "name":"Bristol Channel", "lat":51.5, "lon":-2.9, "radius":[30000,70000], "tilt":45 };
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
@ -224,7 +228,7 @@ Areas, Lines and Circles can also specify more optional properties:
|
|||||||
- fillOpacity
|
- fillOpacity
|
||||||
- dashArray
|
- dashArray
|
||||||
- clickable - if true sets the passed in name as popup
|
- clickable - if true sets the passed in name as popup
|
||||||
- popup - extra html string to display as part of popup
|
- popup - extra html string to display inside the popup
|
||||||
|
|
||||||
## Drawing
|
## Drawing
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-web-worldmap",
|
"name": "node-red-contrib-web-worldmap",
|
||||||
"version": "2.0.2-beta",
|
"version": "2.0.3-beta",
|
||||||
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
"description": "A Node-RED node to provide a web page of a world map for plotting things on.",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cgi": "0.3.1",
|
"cgi": "0.3.1",
|
||||||
|
@ -1060,13 +1060,10 @@ function setMarker(data) {
|
|||||||
if (!data.hasOwnProperty("fillColor")) { opt.fillColor = "blue"; }
|
if (!data.hasOwnProperty("fillColor")) { opt.fillColor = "blue"; }
|
||||||
delete opt.clickable;
|
delete opt.clickable;
|
||||||
var ellipse = L.ellipse(new L.LatLng((data.lat*1), (data.lon*1)), [200000*data.sdlon*Math.cos(data.lat*Math.PI/180), 200000*data.sdlat], 0, opt);
|
var ellipse = L.ellipse(new L.LatLng((data.lat*1), (data.lon*1)), [200000*data.sdlon*Math.cos(data.lat*Math.PI/180), 200000*data.sdlat], 0, opt);
|
||||||
if (data.clickable != false) {
|
if (opt.clickable) {
|
||||||
ellipse.on('click', function(e) {
|
var words = "<b>"+data.name+"</b>";
|
||||||
var popup = L.popup()
|
if (data.popup) { var words = words + "<br/>" + data.popup; }
|
||||||
.setLatLng(new L.LatLng((data.lat*1), (data.lon*1)))
|
ellipse.bindPopup(words, {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200});
|
||||||
.setContent('<p><b>'+data.name+'</b><br/>lat : '+data.lat+'<br/>lon : '+data.lon+'</p>')
|
|
||||||
.openOn(map);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
polygons[data.name] = ellipse;
|
polygons[data.name] = ellipse;
|
||||||
polygons[data.name].lay = lay;
|
polygons[data.name].lay = lay;
|
||||||
@ -1075,8 +1072,18 @@ function setMarker(data) {
|
|||||||
else {
|
else {
|
||||||
if (data.hasOwnProperty("radius")) {
|
if (data.hasOwnProperty("radius")) {
|
||||||
if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) {
|
if (data.hasOwnProperty("lat") && data.hasOwnProperty("lon")) {
|
||||||
var polycirc = L.circle(new L.LatLng((data.lat*1), (data.lon*1)), data.radius*1, opt);
|
var polycirc;
|
||||||
if (opt.clickable) { polycirc.bindPopup(data.name); }
|
if (Array.isArray(data.radius)) {
|
||||||
|
polycirc = L.ellipse(new L.LatLng((data.lat*1), (data.lon*1)), [data.radius[0]*Math.cos(data.lat*Math.PI/180), data.radius[1]], data.tilt || 0, opt);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
polycirc = L.circle(new L.LatLng((data.lat*1), (data.lon*1)), data.radius*1, opt);
|
||||||
|
}
|
||||||
|
if (opt.clickable) {
|
||||||
|
var words = "<b>"+data.name+"</b>";
|
||||||
|
if (data.popup) { var words = words + "<br/>" + data.popup; }
|
||||||
|
polycirc.bindPopup(words, {autoClose:false, closeButton:true, closeOnClick:false, minWidth:200});
|
||||||
|
}
|
||||||
polygons[data.name] = polycirc;
|
polygons[data.name] = polycirc;
|
||||||
polygons[data.name].lay = lay;
|
polygons[data.name].lay = lay;
|
||||||
layers[lay].addLayer(polycirc);
|
layers[lay].addLayer(polycirc);
|
||||||
|
Loading…
Reference in New Issue
Block a user