neocturne/MinedMap

Add marker

Azerxim opened this issue · 3 comments

Hello,

I would like to go beyond in the viewer but I don't understand how to add a marker on the map.

With the Leaflet doc, I understand that you are using the simple CRS but I don't know where to put the marker code to add it?

This depends on what you want to do with the marker, but for a simple static marker, the following works:

--- a/viewer/MinedMap.js
+++ b/viewer/MinedMap.js
@@ -193,6 +193,8 @@ window.createMap = function () {
                var coordControl = new CoordControl();
                coordControl.addTo(map);
 
+               L.marker([64, 64]).addTo(map);
+
                map.on('mousemove', function(e) {
                        coordControl.update(Math.round(e.latlng.lng), Math.round(-e.latlng.lat));
                });

Note that the vertical axis is inverted, so this will add a marker at X=64,Z=-64.

Thank, your software is great

This depends on what you want to do with the marker, but for a simple static marker, the following works:

--- a/viewer/MinedMap.js
+++ b/viewer/MinedMap.js
@@ -193,6 +193,8 @@ window.createMap = function () {
                var coordControl = new CoordControl();
                coordControl.addTo(map);
 
+               L.marker([64, 64]).addTo(map);
+
                map.on('mousemove', function(e) {
                        coordControl.update(Math.round(e.latlng.lng), Math.round(-e.latlng.lat));
                });

Note that the vertical axis is inverted, so this will add a marker at X=64,Z=-64.

How does one add more complicated Markers? Names, custom icons, etc.

Edit: Nvm, found the Leaflet doc