标签:height bounds fun body rip let city map org
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" src="jquery.v1.10.2.js"></script> <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=******"></script> </head> <body> <div id="allmap"></div> <script type="text/javascript"> var marker,map = new AMap.Map("allmap", { resizeEnable: true }); $(function () { $("#allmap").css("height", $(window.parent.document).height() - 123 + "px"); map.plugin(["AMap.CitySearch"], function () { //实例化城市查询类 var citysearch = new AMap.CitySearch(); //自动获取用户IP,返回当前城市 citysearch.getLocalCity(function (status, result) { if (status === ‘complete‘ && result.info === ‘OK‘) { if (result && result.city && result.bounds) { var city = result.city; //var citybounds = result.bounds; //alert(city); console.info(city); //myFun(cityinfo); map.setBounds(result.bounds); } } }); }); var position = []; map.on(‘click‘, function (e) { if (marker) { marker.setMap(null); marker = null; } marker = new AMap.Marker({ icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", position: [e.lnglat.getLng(), e.lnglat.getLat()] }); marker.setMap(map); console.info(position); console.info(e.lnglat.getLng()); console.info(e.lnglat.getLat()); }); }); </script> </body> </html>
标签:height bounds fun body rip let city map org
原文地址:http://www.cnblogs.com/gouzhiguo/p/7423927.html