dceejay / RedMap

A web map app for Node-RED to put blobs on
Apache License 2.0
110 stars 60 forks source link

locally hosted icon #254

Closed pkkrusty closed 1 year ago

pkkrusty commented 1 year ago

Not as much an issue as a noob who doesn't know the right syntax. In documentation, it states "or you can use an inline image of the form data:image/... which uses a base64 encoded image." Is there an example somewhere of a complete statement that would pull the image correctly? I'm not familiar with markup rules.

In my node-red function, I'm defining payload as:

msg.payload = {"name":"pkkrusty", "lat":latitude, "lon":longitude, "icon":"data:image/png;base64,/images/pkkrusty.png"};

But I'm sure that's not right.

dceejay commented 1 year ago

not exactly an issue - better to use the Node-RED discourse forum in future for general How-to questions - but as I happened to spot it

[{"id":"9ccb0bd206b61769","type":"inject","z":"39fd934216580cf2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":100,"y":400,"wires":[["8a42c5ad4f1ed55e"]]},{"id":"8a42c5ad4f1ed55e","type":"function","z":"39fd934216580cf2","name":"marker with inline icon","func":"msg.payload = {\n    name: \"Joe\",\n    lat: 51,\n    lon: -1.33,\n    icon: \"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAAsTAAALEwEAmpwYAAACD0lEQVR4nO2VzUuUURTGf31MbZycmmgkQ1Ahglo1QYugXbiqScF1oORs1JVFBC0EJ+gvaOXa2fQHRKCLChSiRhCMxFqIgShIfoEf4xsXnoHDy/vOl76bYR64zNx7zzn33HOf57zQRBMNhIvACDAL7AC7wJzWLkR9eDtQALyQ8R1oi/LmBR20CGSAuMZT4Kf2vkVViVFzeCJgP2GSyEaRwJyCu5uX8FY8yGneJ5v5kCRDcZvK2FbweMDaluaXDB/+KqFADAFX9f8lUASeVUhgU4EtyXJKYkLzlElgFegNCjRsGHsZGNB8D7gLdAPvgB/AP60X9Ovs+sskmZHNAtAaZpQSkTy9qyvbe83Xgf0yMnNjWT5+nAE+y+ZVhWpyHViS8RfgCvBV8x1V4L4OagEeAJPAgVHCQ1/M1+YSVRGwA/gjp2mgC5gBbmn/BnDH53NPDPdL7RxwDBwBj6gBncCKAn5Us3HoAQ6BX0DS5xMTj5K+ipbevmbclGRcgCdaOy+SekqiPyCRIPJ9oE5kFSBv1q6prVoChiGv/ef1JhCXnl0/SJt119MHxe6NEN+0/DZD1FE1XugWSzV80VyVfstvjBPirNRQendbiSCkzeGfpIQTo0Vq8CSpKeCxKhIT2zN686KRsPM7NcSAN/rAlOuIrjWPSzGRIGUOWzM3LrVaV43I4fnkV0mOjZ9AE01QL/4DAYysDdpFW50AAAAASUVORK5CYII=\"\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":400,"wires":[["d91d3052cf996d48"]]},{"id":"d91d3052cf996d48","type":"worldmap","z":"39fd934216580cf2","name":"","lat":"","lon":"","zoom":"","layer":"OSMG","cluster":"","maxage":"","usermenu":"show","layers":"show","panit":"false","panlock":"false","zoomlock":"false","hiderightclick":"false","coords":"none","showgrid":"false","showruler":"false","allowFileDrop":"false","path":"/worldmap","overlist":"DR,CO,RA,DN","maplist":"OSMG,OSMC,EsriC,EsriS,UKOS","mapname":"","mapurl":"","mapopt":"","mapwms":false,"x":540,"y":400,"wires":[]}]

IE you need to convert the binary of your image into a base64 string (online convertors available) and add that after your data:image/png;base64,

pkkrusty commented 1 year ago

Thanks! That works for me!