LBS配置

js:javascript

<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=3093b00bc02c380333bad7ff269cb30f"></script>

html:html

<form class="form-horizontal form" action="" method="post">
  <h4>LBS配置</h4>
  <table class="tb">
    <tr>
      <th>所在位置</th>
      <td>
        <div id="allmap" style="height:500px;width:500px;">sssssssss</div>
        <input type="text" id="x" value="108.9527" name="x" />
        <input type="text" id="y" name="y" value="34.359132" />
        <div class="help-block">請在地圖中查找到公司的具體位置,並點擊獲取X,Y</div>
      </td>
    </tr>
    <tr>
      <th></th>
      <td>
        <input name="submit" type="submit" value="提交" class="btn btn-primary span3">
        <input type="hidden" name="token" value="4e113bd0">
      </td>
    </tr>
  </table>
</form>

調用:java

<script type="text/javascript">
  // 百度地圖API功能
  var map = new BMap.Map("allmap");
  map.centerAndZoom(new BMap.Point(108.95367, 34.27934), 12);
  function showInfo(e){
    document.getElementById("x").value = e.point.lng; 
    document.getElementById("y").value = e.point.lat;
  }
  map.addEventListener("click", showInfo);
  map.enableScrollWheelZoom(true);
</script>

顯示:api

 

相關文章
相關標籤/搜索