From cbf58dfbf8ddd19dd7b29ae25901a48a1c3acd15 Mon Sep 17 00:00:00 2001 From: 1F616EMO~nya Date: Fri, 7 Jun 2024 01:23:14 +0800 Subject: [PATCH] Put markers at the center of nodes (#374) * Put markers at the center of nodes * Do the fix on every objects --- public/js/map/overlays/AbstractIconOverlay.js | 2 +- public/js/map/overlays/AirUtilsPlanesOverlay.js | 4 ++-- public/js/map/overlays/BorderOverlay.js | 6 +++--- public/js/map/overlays/MinecartOverlay.js | 4 ++-- public/js/map/overlays/PlayerOverlay.js | 4 ++-- public/js/map/overlays/PrivProtectorOverlay.js | 10 +++++----- public/js/map/overlays/ProtectorOverlay.js | 10 +++++----- public/js/map/overlays/TrainOverlay.js | 4 ++-- public/js/map/overlays/TrainlineOverlay.js | 6 +++--- public/js/map/overlays/TrainsignalOverlay.js | 4 ++-- public/js/map/overlays/XPProtectorOverlay.js | 10 +++++----- 11 files changed, 32 insertions(+), 32 deletions(-) diff --git a/public/js/map/overlays/AbstractIconOverlay.js b/public/js/map/overlays/AbstractIconOverlay.js index 2c55c3c..5a1e873 100644 --- a/public/js/map/overlays/AbstractIconOverlay.js +++ b/public/js/map/overlays/AbstractIconOverlay.js @@ -117,7 +117,7 @@ export default L.LayerGroup.extend({ return; } - marker = L.marker([obj.z, obj.x], {icon: icon}); + marker = L.marker([obj.z + 0.5, obj.x + 0.5], {icon: icon}); popup = self.createPopup(obj); if (popup) marker.bindPopup(popup); diff --git a/public/js/map/overlays/AirUtilsPlanesOverlay.js b/public/js/map/overlays/AirUtilsPlanesOverlay.js index 8b9f11d..746e03c 100644 --- a/public/js/map/overlays/AirUtilsPlanesOverlay.js +++ b/public/js/map/overlays/AirUtilsPlanesOverlay.js @@ -66,7 +66,7 @@ export default L.LayerGroup.extend({ }, createMarker: function(plane) { - let marker = L.marker([plane.pos.z, plane.pos.x], {icon: this.getIcon(plane)}); + let marker = L.marker([plane.pos.z + 0.5, plane.pos.x + 0.5], {icon: this.getIcon(plane)}); marker.bindPopup(this.createPopup(plane)); @@ -115,7 +115,7 @@ export default L.LayerGroup.extend({ if (this.currentObjects[plane.id]) { //marker exists let marker = this.currentObjects[plane.id]; - marker.setLatLng([plane.pos.z, plane.pos.x]); + marker.setLatLng([plane.pos.z + 0.5, plane.pos.x + 0.5]); marker.setIcon(this.getIcon(plane)); marker.setPopupContent(this.createPopup(plane)); } else { diff --git a/public/js/map/overlays/BorderOverlay.js b/public/js/map/overlays/BorderOverlay.js index 189862e..ee981dd 100644 --- a/public/js/map/overlays/BorderOverlay.js +++ b/public/js/map/overlays/BorderOverlay.js @@ -63,13 +63,13 @@ export default AbstractGeoJsonOverlay.extend({ //Add stations borders[bordername].forEach(function(entry){ - coords.push([entry.x, entry.z]); + coords.push([entry.x + 0.5, entry.z + 0.5]); }); // closing border coords.push([ - borders[bordername][0].x, - borders[bordername][0].z + borders[bordername][0].x + 0.5, + borders[bordername][0].z + 0.5 ]); var feature = { diff --git a/public/js/map/overlays/MinecartOverlay.js b/public/js/map/overlays/MinecartOverlay.js index bf75430..90ef56b 100644 --- a/public/js/map/overlays/MinecartOverlay.js +++ b/public/js/map/overlays/MinecartOverlay.js @@ -29,7 +29,7 @@ export default L.LayerGroup.extend({ popupAnchor: [0, -32] }); - var marker = L.marker([cart.pos.z, cart.pos.x], {icon: Icon}); + var marker = L.marker([cart.pos.z + 0.5, cart.pos.x + 0.5], {icon: Icon}); var html = "Minecart
"; html += "Id: " + cart.id + "
"; @@ -64,7 +64,7 @@ export default L.LayerGroup.extend({ if (self.currentObjects[cart.id]){ //marker exists - self.currentObjects[cart.id].setLatLng([cart.pos.z, cart.pos.x]); + self.currentObjects[cart.id].setLatLng([cart.pos.z + 0.5, cart.pos.x + 0.5]); //setPopupContent } else { diff --git a/public/js/map/overlays/PlayerOverlay.js b/public/js/map/overlays/PlayerOverlay.js index dd6e060..38b49f2 100644 --- a/public/js/map/overlays/PlayerOverlay.js +++ b/public/js/map/overlays/PlayerOverlay.js @@ -57,7 +57,7 @@ export default L.LayerGroup.extend({ }, createMarker: function(player) { - const marker = L.marker([player.pos.z, player.pos.x], {icon: this.getIcon(player)}); + const marker = L.marker([player.pos.z + 0.5, player.pos.x + 0.5], {icon: this.getIcon(player)}); marker.bindPopup(this.createPopup(player), {minWidth: 220}); return marker; @@ -154,7 +154,7 @@ export default L.LayerGroup.extend({ if (this.currentObjects[player.name]){ //marker exists const marker = this.currentObjects[player.name]; - marker.setLatLng([player.pos.z, player.pos.x]); + marker.setLatLng([player.pos.z + 0.5, player.pos.x + 0.5]); marker.setIcon(this.getIcon(player)); marker.setPopupContent(this.createPopup(player)); diff --git a/public/js/map/overlays/PrivProtectorOverlay.js b/public/js/map/overlays/PrivProtectorOverlay.js index 2fe288b..6466b06 100644 --- a/public/js/map/overlays/PrivProtectorOverlay.js +++ b/public/js/map/overlays/PrivProtectorOverlay.js @@ -11,11 +11,11 @@ export default AbstractGeoJsonOverlay.extend({ "geometry": { "type":"Polygon", "coordinates":[[ - [protector.x-5,protector.z-5], - [protector.x-5,protector.z+6], - [protector.x+6,protector.z+6], - [protector.x+6,protector.z-5], - [protector.x-5,protector.z-5] + [protector.x-5 + 0.5,protector.z-5 + 0.5], + [protector.x-5 + 0.5,protector.z+6 + 0.5], + [protector.x+6 + 0.5,protector.z+6 + 0.5], + [protector.x+6 + 0.5,protector.z-5 + 0.5], + [protector.x-5 + 0.5,protector.z-5 + 0.5] ]] }, "properties":{ diff --git a/public/js/map/overlays/ProtectorOverlay.js b/public/js/map/overlays/ProtectorOverlay.js index e13c399..44c2e49 100644 --- a/public/js/map/overlays/ProtectorOverlay.js +++ b/public/js/map/overlays/ProtectorOverlay.js @@ -15,11 +15,11 @@ export default AbstractGeoJsonOverlay.extend({ "geometry": { "type":"Polygon", "coordinates":[[ - [protector.x-5,protector.z-5], - [protector.x-5,protector.z+6], - [protector.x+6,protector.z+6], - [protector.x+6,protector.z-5], - [protector.x-5,protector.z-5] + [protector.x-5 + 0.5,protector.z-5 + 0.5], + [protector.x-5 + 0.5,protector.z+6 + 0.5], + [protector.x+6 + 0.5,protector.z+6 + 0.5], + [protector.x+6 + 0.5,protector.z-5 + 0.5], + [protector.x-5 + 0.5,protector.z-5 + 0.5] ]] }, "properties":{ diff --git a/public/js/map/overlays/TrainOverlay.js b/public/js/map/overlays/TrainOverlay.js index b1a4ba7..a907669 100644 --- a/public/js/map/overlays/TrainOverlay.js +++ b/public/js/map/overlays/TrainOverlay.js @@ -96,7 +96,7 @@ export default L.LayerGroup.extend({ popupAnchor: [0, -16] }); - var marker = L.marker([train.pos.z, train.pos.x], {icon: Icon}); + var marker = L.marker([train.pos.z + 0.5, train.pos.x + 0.5], {icon: Icon}); marker.bindPopup(this.createPopup(train)); return marker; @@ -134,7 +134,7 @@ export default L.LayerGroup.extend({ if (this.currentObjects[train.id]){ //marker exists let marker = this.currentObjects[train.id]; - marker.setLatLng([train.pos.z, train.pos.x]); + marker.setLatLng([train.pos.z + 0.5, train.pos.x + 0.5]); marker.setPopupContent(this.createPopup(train)); } else { diff --git a/public/js/map/overlays/TrainlineOverlay.js b/public/js/map/overlays/TrainlineOverlay.js index bab87fd..c717dc5 100644 --- a/public/js/map/overlays/TrainlineOverlay.js +++ b/public/js/map/overlays/TrainlineOverlay.js @@ -115,13 +115,13 @@ export default AbstractGeoJsonOverlay.extend({ if (pos == null) { console.warn("[Trainlines][linepath_from_prv]", "line "+linename, "block "+pos_to_string(entry), "index "+entry.attributes.index, "Invalid point:", p); } else { - feat.coords.push([pos.x, pos.z]); + feat.coords.push([pos.x + 0.5, pos.z + 0.5]); } }); } else if (rail_pos) { - feat.coords.push([rail_pos.x, rail_pos.z]); + feat.coords.push([rail_pos.x + 0.5, rail_pos.z + 0.5]); } else { - feat.coords.push([entry.x, entry.z]); + feat.coords.push([entry.x + 0.5, entry.z + 0.5]); } if (entry.attributes.station) { diff --git a/public/js/map/overlays/TrainsignalOverlay.js b/public/js/map/overlays/TrainsignalOverlay.js index 205359b..454918c 100644 --- a/public/js/map/overlays/TrainsignalOverlay.js +++ b/public/js/map/overlays/TrainsignalOverlay.js @@ -50,7 +50,7 @@ export default L.LayerGroup.extend({ createMarker: function(signal){ var Icon = signal.green ? IconOn : IconOff; - var marker = L.marker([signal.pos.z, signal.pos.x], {icon: Icon}); + var marker = L.marker([signal.pos.z + 0.5, signal.pos.x + 0.5], {icon: Icon}); marker.bindPopup(this.createPopup(signal)); return marker; @@ -89,7 +89,7 @@ export default L.LayerGroup.extend({ if (this.currentObjects[signalId]){ //marker exists let marker = this.currentObjects[signalId]; - marker.setLatLng([signal.pos.z, signal.pos.x]); + marker.setLatLng([signal.pos.z + 0.5, signal.pos.x + 0.5]); marker.setPopupContent(this.createPopup(signal)); marker.setIcon(signal.green ? IconOn : IconOff); diff --git a/public/js/map/overlays/XPProtectorOverlay.js b/public/js/map/overlays/XPProtectorOverlay.js index 562bd15..825243f 100644 --- a/public/js/map/overlays/XPProtectorOverlay.js +++ b/public/js/map/overlays/XPProtectorOverlay.js @@ -11,11 +11,11 @@ export default AbstractGeoJsonOverlay.extend({ "geometry": { "type":"Polygon", "coordinates":[[ - [protector.x-5,protector.z-5], - [protector.x-5,protector.z+6], - [protector.x+6,protector.z+6], - [protector.x+6,protector.z-5], - [protector.x-5,protector.z-5] + [protector.x-5 + 0.5,protector.z-5 + 0.5], + [protector.x-5 + 0.5,protector.z+6 + 0.5], + [protector.x+6 + 0.5,protector.z+6 + 0.5], + [protector.x+6 + 0.5,protector.z-5 + 0.5], + [protector.x-5 + 0.5,protector.z-5 + 0.5] ]] }, "properties":{