正常调用百度地图,实现多个点在地图中,并且点击点会弹出提示信息


 
 
  1. jutil.ajax({
  2. url: config.PLATFORM_URL + '/ssa_topntable',
  3. type: 'get',
  4. data: {
  5. offline_attr: '_ass_loophole_ip_position',
  6. index: 'ipweb_result',
  7. type: 'ip_geo_info',
  8. aggField: 'ip_position',
  9. showField: 'ip_position',
  10. page: 1,
  11. size: 100
  12. },
  13. success: function (data) {
  14. var map = MAP.buildMap( 'wordMap', true)
  15. map.setMapStyle({ style: 'dark'})
  16. if (data.code === 0 && data.data.total > 0) {
  17. addMarker( '#wordMap', false)
  18. var _data = data.data.rows
  19. var point, mark
  20. var dictTmp = {}
  21. for ( var i = 0; i < _data.length; i++) {
  22. var itemDict = _data[i]._source
  23. if (itemDict.ip_GeoPosition.D_L) {
  24. var tmpKey = itemDict.ip_GeoPosition.D_L
  25. if (tmpKey in dictTmp) {
  26. dictTmp[tmpKey].doc_count += itemDict.doc_count
  27. }
  28. else {
  29. dictTmp[tmpKey] = {}
  30. dictTmp[tmpKey].D = itemDict.ip_GeoPosition.D_L.split( ',')[ 0]
  31. dictTmp[tmpKey].L = itemDict.ip_GeoPosition.D_L.split( ',')[ 1]
  32. dictTmp[tmpKey].object = itemDict
  33. dictTmp[tmpKey].doc_count = itemDict.doc_count
  34. }
  35. }
  36. }
  37. for ( var tmp2Key in dictTmp) {
  38. var earchItemDict = dictTmp[tmp2Key]
  39. // if(earchItemDict.D != undefined && earchItemDict.D == "暂无经纬度"){
  40. // jutil.ajax({
  41. // url: config.PLATFORM_URL + '/getdl',
  42. // type: 'get',
  43. // data: {},
  44. // success: function (data) {
  45. //
  46. // }
  47. // })
  48. // }
  49. point = MAP.point(earchItemDict.D, earchItemDict.L) //设置地图点的位置
  50. mark = MAP.marker(point) //给每一个点创建标记
  51. map.addOverlay(mark) 将标注添加到地图中
  52. // console.log(earchItemDict.object.ip_GeoPosition);
  53. // console.log(itemDict.ip_GeoPosition.D_L[0], itemDict.ip_GeoPosition.D_L[1]);
  54. mark.setLabel(
  55. MAP.label(earchItemDict.doc_count, {
  56. offset: MAP.size( 20, -10)
  57. })
  58. )
  59. registerEvent(mark, earchItemDict, map)
  60. }
  61. map.centerAndZoom(point, 5) //当然也可以根据城市名称设置地图的中心点:
  62. // openInfoDefault(firstShow["data"], firstShow["map"]);
  63. } else {
  64. map.centerAndZoom(MAP.point( 113.1268217112, 27.8307991014), 5)
  65. }
  66. }
  67. })
  68. function registerEvent (el, obj, m) {
  69. MAP.event( 'click', el, function (data) {
  70. openInfo(obj, data, m)
  71. })
  72. }
  73. function openInfo (obj, g, m) {
  74. var _getPosition = g.target.getPosition()
  75. var opts = {
  76. // width: 200,
  77. // height: 100,
  78. // title: obj.legalityInfo.websponsor,
  79. enableMessage: true
  80. }
  81. var txt = ''
  82. if (obj.doc_count) {
  83. txt += 'IP个数: ' + obj.doc_count + '<br/>'
  84. } else {
  85. txt += 'IP个数: ' + 0 + '<br/>'
  86. }
  87. if (obj.object.ip_GeoPosition.P) {
  88. txt += '地址:' + obj.object.ip_GeoPosition.P + '<br/>'
  89. }
  90. txt += '经纬度:' + _getPosition.lng + ' , ' + _getPosition.lat + '<br/>'
  91. var sendData = obj.object
  92. // var _object = {
  93. // //strIP : sendData.strIP,
  94. // //type: sendData.type,
  95. // //uuid: sendData.uuid,
  96. // ip_position: sendData.ip_position
  97. // };
  98. var _object = {
  99. //strIP : sendData.strIP,
  100. //type: sendData.type,
  101. //uuid: sendData.uuid,
  102. 'ip_GeoPosition.D_L': sendData.ip_GeoPosition.D_L
  103. }
  104. _object = Until.toUrlString(_object)
  105. console.log(_object)
  106. txt += '<a class="tableLink" href="/scan_result/scan_ip_list' + _object + '">查看详情</a>' + '<br/>'
  107. var NEW_window = MAP.infoWindow(txt, opts)
  108. m.openInfoWindow(NEW_window, MAP.point(_getPosition.lng, _getPosition.lat))
  109. }
  110. })

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值