ionic googleMaps

ionic3 项目中 需要googgle地图 国外的项目 但是之前没接触过地图类,想知道谷歌地图 怎么实现 获取本地位置 计算两点之间的距离 等等 希望大神能指导一下 卡了举哀半个月了 一点发都没有 基于ionic3

阅读 2.7k
2 个回答

谷歌api上找的一段,是用h5做的定位

// Try HTML5 geolocation.
if (navigator.geolocation) {
  navigator.geolocation.getCurrentPosition(function(position) {
    var pos = {
      lat: position.coords.latitude,
      lng: position.coords.longitude
    };

    infoWindow.setPosition(pos);
    infoWindow.setContent('Location found.');
    map.setCenter(pos);
  }, function() {
    handleLocationError(true, infoWindow, map.getCenter());
  });
} else {
  // Browser doesn't support Geolocation
  handleLocationError(false, infoWindow, map.getCenter());
}

https://developers.google.cn/...

Google 的 Distance Matrix 服务可使用给定出行方式计算多个起点与终点之间的行程距离和行程持续时间。

https://developers.google.cn/...

推荐问题