Zoho | Integration with Google Maps

|
| By Webner

Problem: Create Google Map with in Zoho and pass address as an arguments to see the Directions on Google map. Also how to find the distance between Source and Destination address.

Solution: To create google map and get directions on the Map all you need is to pass the address in the url:

saddr for start address
daddr for destination address

 

The url would be http://maps.google.com/maps?saddr=Chandigarh+ Sector 35&daddr=Mohali +Sector67

To get the distance between Source and Destination address we need the Logitude and Latitude of the addresses.

To get the Lattitude and Longitude in Zoho we use the xPath builder and pass the url with Source address in the url like this:

googleresp = getUrl("http://maps.google.com/maps/api/geocode/xml?address=" + originaddress1 + "&mode=driving&sensor=false");
latitude = googleresp.executeXPath("/GeocodeResponse/result/geometry/location/lat/text()");
longitude = googleresp.executeXPath("/GeocodeResponse/result/geometry/location/lng/text()");
destinationresp = getUrl("http://maps.google.com/maps/api/geocode/xml?address=" + destinationaddress + "&mode=driving&sensor=false");
destlongitude = destinationresp.executeXPath("/GeocodeResponse/result/geometry/location/lng/text()");
destlatitude = destinationresp.executeXPath("/GeocodeResponse/result/geometry/location/lat/text()");
distanceXML = getUrl("http://maps.google.com/maps/api/directions/xml?origin=" + originaddress1 + "&destination=" + destinationaddress + "&mode=driving&sensor=false");
distance = distanceXML.executeXPath("/DirectionsResponse/route/leg/distance/value/text()");
duration = distanceXML.executeXPath("/DirectionsResponse/route/leg/duration/value/text()");

This way in Zoho deluge we can find the distance and time to travel between two locations. We can change the mode of driving to get the correct time.

Leave a Reply

Your email address will not be published. Required fields are marked *