widget.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <div ref="mouse" style="position: absolute; bottom: 5px; left: 5px;" class="littleWidget">
  3. <span style="padding-left:5px" ref="scale">比例尺:1:125000</span>
  4. <span style="padding-left:5px" ref="location">坐标:</span>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. name: 'MouseLocation',
  10. components: {},
  11. props: {
  12. mapView: {
  13. type: Object,
  14. default: () => []
  15. }
  16. },
  17. data() {
  18. return {}
  19. },
  20. watch: {
  21. mapView: function(e) {
  22. var scale = this.$refs.scale
  23. var location = this.$refs.location
  24. var view = this.mapView
  25. view.TF_mouseLocation = this
  26. this.mapView.on('pointer-move', function(evt) {
  27. var xy = view.toMap({ x: evt.x, y: evt.y })
  28. location.innerHTML = xy ? '坐标:' + xy.x.toFixed(5) + ',' + xy.y.toFixed(5) : '' // that.mapView.zoom+","+that.mapView.resolution+","+that.mapView.scale;//+"\n"+
  29. })
  30. this.mapView.watch('resolution', function(e) {
  31. scale.innerHTML = '比例尺:1:' + view.scale.toFixed(0)
  32. })
  33. }
  34. }
  35. }
  36. </script>