0

I want to create a windows app which calculates the distance between two cities using google maps api.

I can handle this using Javascript code below, however, I don't have an idea how I can call this in windows desktop app.

1-) Can I call this javascript code in C# Windows Application. 2-) Or how can I write the same functionalities in C# Windows Application

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var origin = "The Mary Glowrey Building, 115 Victoria Parade, Fitzroy VIC 3065",
    destination = "building k level/1 St John St, Prahran VIC 3181",
    service = new google.maps.DistanceMatrixService();

service.getDistanceMatrix(
    {
        origins: [origin],
        destinations: [destination],
        travelMode: google.maps.TravelMode.DRIVING,
        avoidHighways: false,
        avoidTolls: false
    }, 
    callback
);

function callback(response, status) {
    var orig = document.getElementById("orig"),
        dest = document.getElementById("dest"),
        dist = document.getElementById("dist");

    if(status=="OK") {
        orig.value = response.destinationAddresses[0];
        dest.value = response.originAddresses[0];
        dist.value = response.rows[0].elements[0].distance.text;
    } else {
        alert("Error: " + status);
    }
}
</script>
</head>
<body>
    <br>
    Basic example for using the Distance Matrix.<br><br>
    Origin: <input id="orig" type="text" style="width:35em"><br><br>
    Destination: <input id="dest" type="text" style="width:35em"><br><br>
      Distance from Statue of Liberty to Washington DC, USA (by car): <input id="dist" type="text" style="width:35em">
</body>
</html>
MareCieco
  • 157
  • 1
  • 19
  • This isn't a duplicate question but you will find your answer here. https://stackoverflow.com/questions/13999187/distance-between-addresses –  Oct 01 '18 at 05:53
  • Unfortunately, Google Maps Platform is deprecated, so, I can't use that solution – MareCieco Oct 01 '18 at 06:05

0 Answers0