linan-0110 4 years ago
parent
commit
1a017e3ef7

+ 1 - 1
src/assets/css/reset.scss

@@ -11,5 +11,5 @@ html,body,#app{
     // overflow: hidden;
 }
 html{
-    // zoom: 50%;
+    zoom: 50%;
 }

+ 6 - 8
src/views/LvShanXiang/LvShanXiang.vue

@@ -79,12 +79,12 @@
                         />
                         <i class="icon_search" @click.stop="search"></i>
                     </main>
-                    <!-- <iframe
-                        src="http://122.237.98.3:8888/LvShanDaShuJu/page/map.html"
+                    <iframe
+                        src="http://hy.ifarmcloud.com/ifarmAmap/index.html"
                         frameborder="0"
                         style="height: 100%; width: 100%"
-                    ></iframe> -->
-                    <Map style="height:100%; width:100%"></Map>
+                    ></iframe>
+                    <!-- <Map style="height:100%; width:100%"></Map> -->
                     <!-- <E-MiddleMap style="height: 100%"></E-MiddleMap> -->
                 </footer>
                 <footer class="footer_2" v-show="!isShowMain">
@@ -132,8 +132,7 @@ import ERight1 from "./charts/ERight1";
 import ERight2 from "./charts/ERight2";
 import ERight3 from "./charts/ERight3";
 
-import Map from "./charts/Map";
-import EMiddleMap from "../Yield/charts/EMiddleMap";
+// import Map from "./charts/Map";
 
 export default {
     name: "LvShanXiang",
@@ -184,8 +183,7 @@ export default {
         ERight1,
         ERight2,
         ERight3,
-        Map,
-        EMiddleMap
+        // Map,
     },
     created() {
         document.title = "吕山牧场";

File diff suppressed because it is too large
+ 169 - 255
src/views/LvShanXiang/charts/Map.vue


+ 195 - 0
src/views/LvShanXiang/charts/Map11.vue

@@ -0,0 +1,195 @@
+<template>
+    <div class="container">
+        <div class="search-box">
+            <el-input
+                v-model="searchKey"
+                @keyup.enter.native="searchByHand"
+                placeholder="请输入内容"
+                class="input-with-select"
+            >
+                <el-button slot="append" icon="el-icon-search" @click="searchByHand"></el-button>
+            </el-input>
+            <!-- <input v-model="searchKey" type="search" id="search" />
+            <button @click="searchByHand">搜索</button>-->
+            <div class="tip-box" id="searchTip"></div>
+        </div>
+        <!--
+          amap-manager: 地图管理对象
+          vid:地图容器节点的ID
+          zooms: 地图显示的缩放级别范围,在PC上,默认范围[3,18],取值范围[3-18];在移动设备上,默认范围[3-19],取值范围[3-19]
+          center: 地图中心点坐标值
+          plugin:地图使用的插件
+          events: 事件
+        -->
+        <el-amap
+            class="amap-box"
+            :amap-manager="amapManager"
+            :vid="'amap-vue'"
+            :zoom="zoom"
+            :plugin="plugin"
+            :center="center"
+            :events="events"
+            mapStyle="fresh"
+        >
+            <!-- 标记 -->
+            <el-amap-marker v-for="(marker, index) in markers" :position="marker" :key="index"></el-amap-marker>
+        </el-amap>
+    </div>
+</template>
+
+
+
+<script>
+import { AMapManager, lazyAMapApiLoaderInstance } from "vue-amap";
+
+let amapManager = new AMapManager();
+export default {
+    data() {
+        let _this = this;
+        return {
+            address: null,
+            searchKey: "",
+            amapManager,
+            markers: [],
+            searchOption: {
+                city: "全国",
+                citylimit: true
+            },
+            center: [121.329402, 31.228667],
+            zoom: 17,
+            lng: 0,
+            lat: 0,
+            loaded: false,
+            events: {
+                init() {
+                    lazyAMapApiLoaderInstance.load().then(() => {
+                        _this.initSearch();
+                    });
+                },
+                // 点击获取地址的数据
+                click(e) {
+                    _this.markers = [];
+                    let { lng, lat } = e.lnglat;
+                    _this.lng = lng;
+                    _this.lat = lat;
+                    _this.center = [lng, lat];
+                    _this.markers.push([lng, lat]);
+                    // 这里通过高德 SDK 完成。
+                    let geocoder = new AMap.Geocoder({
+                        radius: 1000,
+                        extensions: "all"
+                    });
+                    console.log(geocoder);
+                    geocoder.getAddress([lng, lat], function(status, result) {
+                        if (status === "complete" && result.info === "OK") {
+                            if (result && result.regeocode) {
+                                _this.address =
+                                    result.regeocode.formattedAddress;
+                                _this.searchKey =
+                                    result.regeocode.formattedAddress;
+                                _this.$nextTick();
+                            }
+                        }
+                    });
+                }
+            },
+            // 一些工具插件
+            plugin: [
+                // {
+                //   pName: 'Geocoder',
+                //   events: {
+                //     init (o) {
+                //       console.log(o.getAddress())
+                //     }
+                //   }
+                // },
+                {
+                    // 定位
+                    pName: "Geolocation",
+                    events: {
+                        init(o) {
+                            // o是高德地图定位插件实例
+                            o.getCurrentPosition((status, result) => {
+                                console.log(result);
+                                if (result && result.position) {
+                                    // 设置经度
+                                    _this.lng = result.position.lng;
+                                    // 设置维度
+                                    _this.lat = result.position.lat;
+                                    // 设置坐标
+                                    _this.center = [_this.lng, _this.lat];
+                                    _this.markers.push([_this.lng, _this.lat]);
+                                    // load
+                                    _this.loaded = true;
+                                    // 页面渲染好后
+                                    _this.$nextTick();
+                                }
+                            });
+                        }
+                    }
+                },
+                {
+                    // 工具栏
+                    pName: "ToolBar",
+                    events: {
+                        init(instance) {
+                            console.log(instance);
+                        }
+                    }
+                },
+                {
+                    // 鹰眼
+                    pName: "OverView",
+                    events: {
+                        init(instance) {
+                            console.log(instance);
+                        }
+                    }
+                },
+                
+                {
+                    // 搜索
+                    pName: "PlaceSearch",
+                    events: {
+                        init(instance) {
+                            console.log(instance);
+                        }
+                    }
+                }
+            ]
+        };
+    },
+    methods: {
+        initSearch() {
+            let vm = this;
+            let map = this.amapManager.getMap();
+            AMapUI.loadUI(
+                [
+                    "overlay/SimpleMarker", //SimpleMarker
+                    "overlay/SimpleInfoWindow" //SimpleInfoWindow
+                ],
+                function(SimpleMarker, SimpleInfoWindow) {
+                    console.dir(SimpleMarker)
+
+                    //....引用加载的UI....
+                }
+            );
+        },
+        searchByHand() {
+            console.log("666");
+            // this.poiPicker.searchByKeyword(this.searchKey)
+        }
+    }
+};
+</script>
+
+
+<style lang="scss" scope>
+.container {
+    width: 100%;
+    height: 100%;
+    .search-box {
+        margin-bottom: 15px;
+    }
+}
+</style>

+ 2 - 2
src/views/Yield/Yield.vue

@@ -56,8 +56,8 @@
                 </div>
             </div>
             <div class="center">
-                <E-MiddleMap style="height: 100%"></E-MiddleMap>
-                <!-- <img src="../../assets/9bce2ea1dc3f5a0faeae227ad9ee24c.png" style="height: 100%; width: 100%"> -->
+                <!-- <E-MiddleMap style="height: 100%"></E-MiddleMap> -->
+                <img src="../../assets/9bce2ea1dc3f5a0faeae227ad9ee24c.png" style="height: 100%; width: 100%">
             </div>
             <div class="right">
                 <div class="warp">