简体   繁体   English

计算2个位置谷歌地图Api之间的距离

[英]Calculate the distance between 2 position Google maps Api

We want to create a Line Bus of our City , what kind of Maps Api , we can use , My friend proposed to use Google Map Api.我们要创建一个我们城市的Line Bus,我们可以使用什么样的Maps Api,我的朋友建议使用Google Map Api。 We want to know howto get the distance between 2 places in meter , i found the method distanceFrom() and it generate the distance in the air and not between street .我们想知道如何以米为单位获得 2 个地方之间的距离,我找到了 distanceFrom() 方法,它生成了空气中的距离,而不是街道之间的距离。 We have a Table of Address , and we want to compare it with a position who came from the user to find the Closest address.我们有一个地址表,我们想将它与来自用户的位置进行比较以找到最近的地址。 so we need to find the lower distance between the position and all the list of address in the table.所以我们需要找到位置和表中所有地址列表之间的较低距离。

My code is get distance of 2 point or 2 location in map with google map deriction service我的代码是使用 google map deriction 服务在地图中获得 2 点或 2 个位置的距离

    var PolylineOption = {
        strokeColor : "blue",
        strokeOpacity : 0.5,
        strokeWeight : 5
    };
    var request = {
        origin : polyline[0].start, // điểm đầu
        waypoints : polyline[1].waypoint,
        destination : polyline[2].end, // Điểm cuối
        optimizeWaypoints : true,
        travelMode : google.maps.TravelMode.DRIVING
    };
    rendererOptions = {
                draggable : true,
                suppressMarkers : true,
                polylineOptions : this.PolylineOption
    };
    var Service = new google.maps.DirectionsService();
    var Display = new google.maps.DirectionsRenderer(rendererOptions);
    Display.setMap(map);
    Service.route(this.request, function(response, status) {
        if (status == google.maps.DirectionsStatus.OK) {
            distance += response.routes[0].legs[0].distance.value;
            // distance of 2 location
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Google Maps API DistanceMatrixService计算API中当前位置和用户位置之间的距离 - Calculate the distance between my current location and user locations from API with Google Maps API DistanceMatrixService 使用Google Maps API之间的距离 - Distance between several latlng with Google maps API 如何计算点之间的距离Google Maps Api V3 - How Would I Calculate The Distance Between The Points Google Maps Api V3 是否可以使用Google Maps API V3通过陆运计算两个英国邮政编码之间的距离? - Is it possible to calculate distance by land transport between two UK postcodes using Google Maps API V3? 使用Google Maps API V3计算当前位置与不同位置之间的距离 - Calculate distance between current location and and a different location using Google Maps API V3 如何使用Google Maps API计算两个以上的点之间的距离? - How to calculate distance between more than two points with google maps api? 计算谷歌地图V3中两点之间的距离 - Calculate distance between two points in google maps V3 是否可以计算angular-google-maps中两个标记之间的距离? - Is it possible to calculate distance between two markers in angular-google-maps? Google Maps API v3同步计算距离和持续时间 - Google Maps API v3 calculate distance ,duration Synchronously 如何使用Google Maps API路线计算每个国家/地区的距离 - How to calculate distance for each country using Google Maps API Route
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM