dever 6 years ago
parent
commit
a6a6c65cee
4 changed files with 92 additions and 1 deletions
  1. 28 0
      assets/moltran/html/map.html
  2. 7 1
      config/base.php
  3. 45 0
      src/Lib/Input.php
  4. 12 0
      template/default/map.php

+ 28 - 0
assets/moltran/html/map.html

@@ -0,0 +1,28 @@
+<!doctype html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
+    <title>关键字检索</title>
+    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
+    <style type="text/css">
+        #panel {
+            position: absolute;
+            background-color: white;
+            max-height: 90%;
+            overflow-y: auto;
+            top: 10px;
+            right: 10px;
+            width: 280px;
+        }
+    </style>
+    <script id="map" type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.8&key={key}"></script>
+    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
+</head>
+<body>
+<div id="container"></div>
+<div id="panel"></div>
+<script type="text/javascript" src="../script/lib/map/gaode.js"></script>
+</body>
+</html>

+ 7 - 1
config/base.php

@@ -17,7 +17,13 @@ $config['base'] = array
 	'getAdmin' => true,
 
 	# 开启批量更新
-	'mul_type' => 1
+	'mul_type' => 1,
+
+	# 地图配置
+	'map' => array
+	(
+		'url' => 'https://webapi.amap.com/maps?v=1.4.8&key=b51a0d5f8f977726eeaa070a30bcf3cd',
+	),
 );
 
 # 模板配置

+ 45 - 0
src/Lib/Input.php

@@ -5,6 +5,51 @@ use Dever;
 
 class Input
 {
+    /**
+     * 地图
+     *
+     * @return string
+     */
+    public static function map($param)
+    {
+        $url = Dever::url('map', 'manage');
+
+        $html = self::text($param);
+
+        $id = $param['name'] . '_value';
+        $iframe_id = $id . '_map';
+
+        $html .= '<iframe id="'.$iframe_id.'" src="'.$url.'" style="margin-top:10px;display: block;" width="800" height="500" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowtransparency="yes" onload="mapLoad()"></iframe>';
+
+        $html .= '<script>$(function()
+        {
+            $("#'.$id.'").blur(function()
+            {
+                layui.layer.msg("搜索中...");
+                $("#'.$iframe_id.'")[0].contentWindow.search($(this).val());
+            });
+        });
+        function mapLoad(){
+            if ($("#'.$id.'").val()) {
+                $("#'.$iframe_id.'")[0].contentWindow.showMaker($("#'.$id.'").val());
+            }
+        }
+        function closeMsg() {
+            layui.layer.closeAll();
+        }
+        function setMap(x, y, z) {
+                var val = $("#'.$id.'").val();
+                if (val) {
+                    var temp = val.split(",");
+                    val = temp[0];
+                }
+                $("#'.$id.'").val(val + "," + x + "," + y + "," + z);
+            }</script>';
+
+        return $html;
+    }
+
+
     /**
      * desc
      *

+ 12 - 0
template/default/map.php

@@ -0,0 +1,12 @@
+<?php
+/*
+|--------------------------------------------------------------------------
+| home
+|--------------------------------------------------------------------------
+*/
+$view
+
+# 新增parse功能,能够将#map@src里的内容的{key}替换为这个值
+->fetch('#map@src', '<{Dever::config("base")->map["url"]}>')
+# display
+->display();