# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for
Did you mean:
Partner

Hi Community,

I saw a Mike Tarallo video Qlik Sense - Developer Hub - YouTube (about howto create an extension by javascritp - simple table)

and I have a question.

Is it possibile to calculate a distance from <city> to <city>

or

Is it possible to create a map from <city> to <city>?

Howto?

Specialist

Hi Fabio,

If you are happy using the Google Maps Javascript api here is some code that will help you calculate the distance between 2 markers :

var start = markerArray[0].getPosition();

var end = markerArray[1].getPosition();

var diff = calculateDistances(start,end).miles;

//--------------------------------------

// Purpose: Calculate the distance between 2 markers

//

//--------------------------------------

function calculateDistances(start,end) {

var stuDistances = {};

stuDistances.metres = google.maps.geometry.spherical.computeDistanceBetween(start,end);    // distance in metres rounded to 1dp  --computeDistanceBetween = shortest path

stuDistances.km = Math.round(stuDistances.metres / 1000 *10)/10;                // distance in km rounded to 1dp

stuDistances.miles = Math.round(stuDistances.metres / 1000 * 0.6214 *10)/10;            // distance in miles rounded to 1dp

return stuDistances;

}

Thanks

Mark

techstuffy.com

Tags
Community Browser