C端蜂鸟地图
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

33 rivejä
961 B

  1. function getRandomCoords(bound) {
  2. let minX = bound.min.x;
  3. let minY = bound.min.y;
  4. let maxX = bound.max.x;
  5. let maxY = bound.max.y;
  6. var _x = Math.floor(Math.random() * (maxX - minX)) + minX;
  7. var _y = Math.floor(Math.random() * (maxY - minY)) + minY;
  8. return { x: _x, y: _y }
  9. }
  10. var _markers = []
  11. function _randomDomMarker(map, num) {
  12. for (let index = 0; index < num; index++) {
  13. var domMarker = new fengmap.FMDomMarker({
  14. x: getRandomCoords(map.getBound()).x,
  15. y: getRandomCoords(map.getBound()).y,
  16. content: '<p class="my-popup">' + getRandomCoords(map.getBound()).x + '</p>',
  17. domWidth: 10,
  18. domHeight: 10
  19. });
  20. var level = map.getLevel()
  21. var floor = map.getFloor(level);
  22. domMarker.addTo(floor);
  23. _markers.push(domMarker)
  24. }
  25. }
  26. function _clearAllDomMarker() {
  27. _markers.forEach(marker => {
  28. marker.remove();
  29. });
  30. }