【问题标题】:Need to get nearest map markers using zipcode in angular 5需要使用角度 5 中的邮政编码获取最近的地图标记
【发布时间】:2018-03-09 15:39:12
【问题描述】:

我希望能够使用 Angular 5 根据邮政编码找到最近的地图标记。谷歌地图标记来自我创建的数据库。我知道我可以使用 Google Geocode Api 将邮政编码转换为纬度和经度,但我不知道从那里去哪里。

是否有 Angular 库可以计算 Google 地图标记与给定纬度和经度之间的距离?我正在寻找类似于商店定位器搜索的东西,但我不知道该怎么做。

【问题讨论】:

    标签: angular google-maps google-maps-api-3


    【解决方案1】:

    这是计算2个标记之间距离的方法

    var distance = google.maps.geometry.spherical.computeDistanceBetween(marker, zipcode);
    

    https://developers.google.com/maps/documentation/javascript/geometry?hl=fr#Distance

    【讨论】:

    • 我是否需要遍历您提供的函数中的所有标记以根据特定距离查找最近的标记?
    猜你喜欢
    • 2011-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多