| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- <template>
- <view>
- <view class="">
- <view class="">
- <map id="map" class="mapbody" :style="'height:'+mapHeight+'rpx;'" :markers="covers" @regionchange="regionChange">
- </map>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- name:"mapView",
- props: {
- pcovers:'',
-
- },
- data() {
- return {
- mapHeight:0,
- mapready:false,
- covers:[],
- includePoints:[],
- dcovers: [{
- latitude: 39.909,
- longitude: 116.39742,
- iconPath: '/static/images/dizhil@3x.png'
- }, {
- latitude: 39.90,
- longitude: 116.39,
- iconPath: '/static/images/dizhil@3x.png'
- }]
- };
- },
- created() {
- var info = uni.getSystemInfoSync();
- console.log(info);
- this.mapHeight=info.windowHeight/2;
- this.mapContext = uni.createMapContext("map",this);
- console.log("1----------------------");
- },
-
- watch: {
- pcovers(val){
- this.covers = this.pcovers;
- let include = [];
- for(var i=0;i<this.covers.length;i++){
- let poi = {
- longitude: this.covers[i].longitude,
- latitude: this.covers[i].latitude
- }
- include.push(poi);
- }
-
- this.includePoints = include;
- this.mapContext.includePoints({
- padding:[180,180,180,180],
- include
- })
- console.log('includePoints',this.includePoints);
- }
- },
- methods: {
- regionChange(){
- var that = this;
- if(!this.mapready){
- return;
- }
-
- this.mapContext.getCenterLocation({
- success: res => {
- console.log('getCenterLocation');
- },
- fail: res => {
- console.log("getCenterLocation11")
- }
- })
- },
- },
- }
- </script>
- <style>
-
- .mapbody{
- width: 100%;
- }
- </style>
|