• 地图点击出弹窗


    1. //初始化地图
    2. let heatMap = new AMap.Map('heatMapContainer', {
    3. resizeEnable: true, //是否监控地图容器尺寸变化
    4. mapStyle: "amap://styles/497004ae2c51a8533ae790fa18b72c5e",
    5. center: [121.474198,31.220791],
    6. zoom: 14, //初始地图级别
    7. features: ['bg', 'road', 'building', 'point'],
    8. zooms: [13,18]
    9. });
    1. // 高德地图点击获取经纬度
    2. heatMap.on('click', function(e) {
    3. setTimeout( () => {
    4. if(!clickMove) return;
    5. $('.loading').show()
    6. $.ajax({
    7. url: setPathInit() + '/vios/commandDataBound/getDataByXYAndTimeStr',
    8. data: {
    9. xAxis: e.lnglat.getLng(),
    10. yAxis: e.lnglat.getLat(),
    11. timeStr: collectNowHeatMapTime.replace('R','')
    12. },
    13. type: "POST",
    14. dataType: "json",
    15. success: function (data) {
    16. if(data.code != 500) {
    17. $('.loading').hide()
    18. var icon = new AMap.Icon({
    19. image: ctx + '/views2/pages/demonstration/img/heatMapPointImg.png',
    20. size: new AMap.Size(30, 30)
    21. });
    22. var marker = new AMap.Marker({
    23. map: heatMap,
    24. icon,
    25. position:new AMap.LngLat(data.xAxis,data.yAxis),
    26. title: data.id,
    27. extData: data.data
    28. });
    29. collectHeatMapPointIndex++;
    30. marker.setLabel({
    31. offset: new AMap.Pixel(-100, -100), //设置文本标注偏移量
    32. content: `
    33. ${collectHeatMapPointIndex}">
    34. 名称:${data.id}

    35. 压力:${parseInt(data.data)} kPa

    36. 时间:${data.time}

    37. ${data.id}','heatMapBox${collectHeatMapPointIndex}')">
    38. ${data.id}','heatMapBox${collectHeatMapPointIndex}')">x
  • `,
  • direction: 'top'
  • });
  • heatMap.add(marker)
  • collectHeatMapPoint.push(marker)
  • if(collectHeatMapPoint.length > 0) {
  • $('.removeAllHeatMapPoints').show()
  • }
  • } else {
  • showTipsDialog(9)
  • }
  • }
  • })
  • },300)
  • });
    1. // 固定选中的 热力图 压力点
    2. function dragHeatMapBox(name, idClass) {
    3. clickMove = false;
    4. setTimeout(()=> {
    5. clickMove = true
    6. },800)
    7. collectHeatMapPoint.forEach( item => {
    8. if(item.getTitle() == name) {
    9. var oldTop = $('#'+idClass).offset().top;
    10. var oldLeft = $('#'+idClass).offset().left;
    11. $('#heatMapContainer').prepend($('#'+idClass).clone())
    12. item.setLabel({
    13. offset: new AMap.Pixel(0, 0), //设置文本标注偏移量
    14. content: '',
    15. direction: 'top'
    16. });
    17. $('#'+idClass).css('top', oldTop + 'px')
    18. $('#'+idClass).css('left', oldLeft + 'px')
    19. $('#'+idClass).attr('ondblclick',`moveHeatMapPointJump('${item.getTitle()}','${idClass}')`)
    20. $('#'+idClass + ' .moveHeatMapBox').hide()
    21. }
    22. })
    23. }

  • 相关阅读:
    JVM内存模型之深究模型特征
    使用RCurl和R来爬虫视频
    插入排序问题
    IDE常用快捷键整理及使用指南
    程序规范化编写
    【Arduino+ESP32专题】SD卡的驱动
    mybatis mapper.xml转建表语句
    ArcGis for JavaScript 4.23版本接入国家天地矢量地图
    基于Zookeeper搭建Kafka高可用集群(实践可用)
    面试题五:computed的使用
  • 原文地址:https://blog.csdn.net/qq_44161703/article/details/127669089