javaee论坛

普通会员

225648

帖子

334

回复

348

积分

楼主
发表于 2017-08-18 09:00:57 | 查看: 94 | 回复: 1

api官网:

http://api.map.soso.com/doc_v2/example.html?sample-geocoding-simple#8map



示例代码如下(保存为html打开可见效果):

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>按关键字查询</title><script charset="utf-8" src="http://map.soso.com/api/v2/main.js"></script><script>var geocoder,map,marker = null;var init = function() {    var center = new soso.maps.LatLng(39.916527,116.397128);    map = new soso.maps.Map(document.getElementById('iCenter'),{        center: center,        zoom: 15    });    geocoder = new soso.maps.Geocoder({        complete : function(result){            map.setCenter(result.detail.location);            var marker = new soso.maps.Marker({                map:map,                position: result.detail.location,                title:result.detail.address+result.detail.location            });        },        error : function(result){        	$("#iCenter").empty();       $("#iCenter").append("检索没有结果,原因: " + result);                  }                    });}function codeAddress() {    var address = "成都市金河路口宽窄巷子";    geocoder.getLocation(address);}var showmap = function() {init();codeAddress();}</script></head><body onload="showmap();">          <div id="iCenter" style="height:300px;width=661px "></div>            </body></html>



普通会员

0

帖子

296

回复

302

积分
沙发
发表于 2024-02-25 01:54:51

谢谢楼主分享

您需要登录后才可以回帖 登录 | 立即注册

触屏版| 电脑版

技术支持 历史网 V2.0 © 2016-2017