<template><vue2ol-mapstyle="height:400px;"><vue2ol-view:zoom="zoom":center="center":options="viewOptions"></vue2ol-view><vue2ol-layer-tile><vue2ol-source-osm></vue2ol-source-osm></vue2ol-layer-tile><vue2ol-layer-vector:zIndex="10"><vue2ol-source-vector:features="features"></vue2ol-source-vector><vue2ol-event-vector@on-singleclick="handleSingleClick"@on-pointermove="handlePointerMove"></vue2ol-event-vector></vue2ol-layer-vector></vue2ol-map></template><script>import Feature from"ol/Feature";import Point from"ol/geom/Point";exportdefault{data(){return{zoom:10,//级别center:[120,28],//中心点viewOptions:{projection:"EPSG:4326"//坐标系},features:[]};},mounted(){for(let i =0; i <10; i++){let feature =newFeature({geometry:newPoint([120+ i *0.01,28+ i *0.01])});this.features.push(feature);}},methods:{handleSingleClick(result){
console.log("handleSingleClick", result);},handlePointerMove(result){
console.log("handlePointerMove", result);}}};</script>