Skip to content

Dragging button isn't in the middle of the map #44

Open
@hejustbrave

Description

@hejustbrave

1653299024(1)

1653299041(1)
and my code is:

<script> import { onMounted, reactive } from "@vue/runtime-core"; import DrawTool from "./components/drawTool.vue"; // import {} from "leaflet-splitmap";

export default {
name: "App",
components: {
DrawTool,
},
setup() {
// console.log(a);
let L = window.L;
let map = reactive({});
let data = reactive({ myMap: null });
onMounted(() => {
map = L.map("map", {
// 初始化地图信息
crs: L.CRS.EPSG4326,
center: { lat: 22.791758946936532, lng: 113.52616661006695 },
maxZoom: 18,
zoom: 14,
});
data.myMap = map;
require("leaflet-side-by-side");
require("leaflet-splitmap");
var myLayer2 = L.supermap.tiandituTileLayer({
layerType: "vec",
// url:'http://t0.tianditu.gov.cn/cva_c/wmts?',
key: "49d42799e2f10cf2d3c1d24c02cdb71f",
// isLabel:true
}).addTo(map);

  var myLayer1 = L.supermap.tiandituTileLayer({
      layerType: "img",
      key: "49d42799e2f10cf2d3c1d24c02cdb71f",
      // isLabel: true,
    }).addTo(map);
    
    L.control.sideBySide(myLayer2,myLayer1).addTo(map);

  // map.on("mouseup", (e) => {
  //   let latlng = e.latlng;
  //   console.log(latlng); // {lat: 30.59, lng: 114.32}
  //   console.log(map.getZoom()); // {lat: 30.59, lng: 114.32}
  // });
});
return {
  data,
};

},
};
</script>

<style> body { margin: 0; } #app { font-family: Avenir, Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-align: center; color: #2c3e50; } #map { position: absolute; left: 0px; right: 0px; width: 100%; height: 100%; } </style>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions