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


My code is get distance of 2 point or 2 location in map with google map deriction service

    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
        }
    });

solved Calculate the distance between 2 position Google maps Api