1.在百度地圖申請ak碼
2.在項目中index.html中引用
<script type="text/javascript" src="http://api.map.baidu.com/api?...;ak=YOU_AK"></script>
3.在你要使用的ts中添加
declare var BMap;
4.在你的方法中就能夠使用百度的api了
例:javascript
var geolocation = new BMap.Geolocation(); geolocation.getCurrentPosition(function(r){ console.log(r.point.lat,r.point.lng); });