Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function callback(data, stops) {
- $("#results").val(JSON.stringify(data, undefined, 4));
- var bbox = data.route.boundingBox;
- var sesh = data.route.sessionId;
- var url = constructStaticMapURL(sesh, bbox, stops, $(window).width(), $(window).height());
- showImage(url, $(window).width(), $(window).height())
- }
- function constructStaticMapURL(sessionID, boundingBox, stops, width, height) {
- var stopsString = ''
- if(stops.length > 0) {
- stopsString = '&locations='
- for(var i = 0; i < stops.length; i++) {
- stopsString += stops[i]
- stopsString += '|marker-' + (i+1)
- if(i + 1 < stops.length) {
- stopsString += '||'
- }
- }
- console.log(stopsString)
- }
- var ullat, ullong, lrlat, lrlong;
- ullat = boundingBox.ul.lat;
- ullong = boundingBox.ul.lng;
- lrlat = boundingBox.lr.lat;
- lrlong = boundingBox.lr.lng;
- var URL = 'https://www.mapquestapi.com/staticmap/v5/map?' + 'key=' + key
- + '&session=' + sessionID + stopsString
- + '&boundingBox=' + ullat + ','
- + ullong + ',' + lrlat + ',' + lrlong
- + '&size=' + width + ',' + height;
- console.log(URL);
- return URL; //this will be the src parameter in the showImage function
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement