POI.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /** * POI点
  2. *
  3. */
  4. import PubSub from "pubsub-js";
  5. import MapUtil from "../utils/MapUtil";
  6. import App from "../App";
  7. export default class POI{
  8. /** * POI点
  9. * @param {Number} id - POI id
  10. * @param {Number} x - POI x坐标
  11. * @param {Number} y - POI y坐标
  12. * @param {String} name - POI 名称
  13. * @param {Array<String>} info - jsx详细信息
  14. * @param {String} src - 标记图标路径
  15. */
  16. constructor(id, x, y, name, info, src){
  17. let latlng = MapUtil.distancePointToLatLng(App.origin, x, y);
  18. this.lat = latlng.lat;
  19. this.lng = latlng.lng;
  20. this.src = src ? src : "img/move.png";
  21. this.info = info;
  22. this.name = name;
  23. this.id = id;
  24. }
  25. add(){
  26. PubSub.publish('map.poi.add', this);
  27. }
  28. // move(x, y){
  29. // let latlng = MapUtil.distancePointToLatLng(App.origin, x, y);
  30. // this.lat = latlng.lat;
  31. // this.lng = latlng.lng;
  32. // PubSub.publish('map.poi.move', this);
  33. // }
  34. remove(){
  35. PubSub.publish('map.poi.remove', this);
  36. }
  37. }