JSDM

HTML

6
1
<input type="text" placeholder="请输入关键字进行搜索" id="tipinput">
2
<input type="text" readonly id="getLng" value="108.947179">
3
<input type="text" readonly id="getLat" value="34.269991">
4
<div id="container" style="width:800px; height:600px;">地图正在加载中,请稍后......</div>
5
<script src="http://webapi.amap.com/maps?v=1.3&key=c6922b496ade0007d4795385aa6d235a&callback=init&plugin=AMap.Autocomplete"></script>
6
!

CSS

xxxxxxxxxx
1
 
1
!
? ?
? ?
必须是有效的URL
+ 添加另一个资源

JS

35
 
1
  function init(){
2
    //初始化地图对象,加载地图
3
    var map = new AMap.Map("container", {
4
      resizeEnable: true,
5
    });
6
    var auto = new AMap.Autocomplete({
7
      input: "tipinput"
8
    });
9
    AMap.event.addListener(auto,"select",select);//监听,选记录时触发
10
    
11
    function select(e) {
12
      if (e.poi && e.poi.location) {
13
        map.setZoom(15);
14
        map.setCenter(e.poi.location);
15
      }
16
    }
17
    
18
    var clickEventListener = map.on('click', function(e) {
19
      var getLngs = e.lnglat.getLng();
20
      var getLats = e.lnglat.getLat();
21
      document.getElementById("getLng").value = getLngs;
22
      document.getElementById("getLat").value = getLats;
23
      map.clearMap();// 清除地图覆盖物
24
      //添加点标记
25
      new AMap.Marker({
26
        map: map,
27
        position: [getLngs,getLats],
28
        icon: new AMap.Icon({
29
          size: new AMap.Size(32,34),  //图标大小
30
          image: "http://webapi.amap.com/images/marker_sprite.png",
31
        })
32
      });
33
    });
34
  }
35
!
必须是有效的URL
+ 添加另一个资源
Close

文件管理 点击文件查看URL

图片

  1. 暂无文件

CSS

  1. 暂无文件

JavaScript

  1. 暂无文件

其他

  1. 暂无文件
拖动文件到上面的区域或者:
加载中 ..................