Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PointOverlay 的 setSelectedList 方法报错 #69

Closed
louyanqi opened this issue Mar 8, 2019 · 0 comments
Closed

PointOverlay 的 setSelectedList 方法报错 #69

louyanqi opened this issue Mar 8, 2019 · 0 comments

Comments

@louyanqi
Copy link

louyanqi commented Mar 8, 2019

image

实现:
点击表格中的数据,选中地图上的点。

问题:
image

代码:

`
import inMap from 'inmap'
import { mapState } from 'vuex'
import { map_theme } from '@/utils/theme'
export default {
name: 'BaseMap',
props: {
cityList: Array,
showType: String
},
data() {
return {
inmap: null,
map: null,
geoData: [],
pointlayer: null
}
},
mounted() {
this.initMap()
},
watch: {
cityList() {
this.addPoint()
},
currentCity() {
let choose = this.$.find(this.geoData, x=>{
return x.info.id == this.currentCity.id
})
if (choose){
let selectedList = [choose]
console.log(selectedList)
console.log(this.pointlayer)
this.pointlayer.setSelectedList(selectedList)
}
}
},
computed: {
...mapState(['currentCity']),
colors() {
return this.$
.map(pmcolors, x=>{return x.bgcolor})
}
},
methods: {
initMap(){
var inmap = new inMap.Map({
id: 'allmap',
skin: "Blueness",
center: [105.403119, 38.028658],
zoom: {
value: 5, //当前地图级别
show: true, //放大缩小按钮显示
max: 18,
min: 5
},
})

  let map = inmap.getMap()
  this.inmap = inmap
  this.map = map
  // map.setMapStyle(map_theme)
},
addPoint() {
  let data = []
  for (let i of this.cityList){
    if (!i.point){
      continue
    }
    let val = i[this.showType]
    if (!val){
      val = 0
    }
    data.push({
      "count": val,
      "info": i,
      "geometry": {
        "type": "Point",
        "coordinates": [i.point.lng, i.point.lat]
      }
    })
  }
  this.geoData = data
  var overlay = new inMap.PointOverlay({
    event: {
      onMouseClick(item, event) {
        console.log('click', item)
      }
    },
    selected: [

    ],
    style: {
      normal: {
        backgroundColor: "rgba(200, 200, 50)", // 填充颜色
        globalCompositeOperation: "source-over", // 颜色叠加方式
        size: 8 // 半径
      },
      colors: this.colors,
      mouseOver: {
        borderColor: "rgba(255,255,255,1)",
        borderWidth: 1
      },
      selected: {
        borderWidth: 1,
        borderColor: "rgba(255,255,255,1)"
      }
    },
    legend: {
      show: true,
      title: "图例"
    },
    data: data
  });
  this.pointlayer = overlay
  this.inmap.add(overlay);
}

}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant