Survey
164
en
gid
sid
group_name
group_order
description
language
randomization_group
grelevance
qid
parent_qid
sid
gid
type
title
question
preg
help
other
mandatory
question_order
language
scale_id
same_default
relevance
$(document).ready(function(){
// Identify the map
var mapSGQA = '{SGQ}';
var currentMap = gmaps[''+mapSGQA+'_c'];
// Wait for the map to load
google.maps.event.addListenerOnce(currentMap, 'idle', function(){
// Some variable definitions
var currentMarker = gmaps['marker__'+mapSGQA+'_c'];
var answerInput = $('#answer'+mapSGQA+'_c');
var defaultPosition = $(answerInput).val();
var startLat = $('#answer'+mapSGQA+'_c').val().split(' ')[0];
var startLng = $('#answer'+mapSGQA+'_c').val().split(' ')[1];
var startLatLng = new google.maps.LatLng(startLat, startLng);
var originIcon = 'https://chart.googleapis.com/chart?chst=d_map_pin_letter&chld=O|FFFF00|000000';
// Listener on the map events
google.maps.event.addListener(currentMap, 'click', function() {
calculateDistances(startLatLng, currentMarker.getPosition());
});
google.maps.event.addListener(currentMarker, 'dragend', function() {
calculateDistances(startLatLng, currentMarker.getPosition());
});
google.maps.event.addListener(currentMap, 'rightclick', function() {
calculateDistances(startLatLng, currentMarker.getPosition());
});
// Insert the results element
$(answerInput).after('');
});
});
function calculateDistances(origin, destination) {
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [origin],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
}, callback);
}
function callback(response, status) {
if (status != google.maps.DistanceMatrixStatus.OK) {
alert('Error was: ' + status);
} else {
var origins = response.originAddresses;
var destinations = response.destinationAddresses;
var outputDiv = $('.questiontext');
outputDiv.innerHTML = '';
for (var i = 0; i < origins.length; i++) {
var results = response.rows[i].elements;
for (var j = 0; j < results.length; j++) {
$('.distanceResults').html('Start address: '+origins[i]+'
\
End address: '+destinations[j]+'
\
Distance: '+results[j].distance.text+'
\
Time: '+results[j].duration.text+'');
}
}
}
}
]]>
qid
attribute
value
language
sid
admin
expires
startdate
adminemail
anonymized
faxto
format
savetimings
template
language
additional_languages
datestamp
usecookie
allowregister
allowsave
autonumber_start
autoredirect
allowprev
printanswers
ipaddr
refurl
publicstatistics
publicgraphs
listpublic
htmlemail
sendconfirmation
tokenanswerspersistence
assessments
usecaptcha
usetokens
bounce_email
attributedescriptions
emailresponseto
emailnotificationto
tokenlength
showxquestions
showgroupinfo
shownoanswer
showqnumcode
bouncetime
bounceprocessing
bounceaccounttype
bounceaccounthost
bounceaccountpass
bounceaccountencryption
bounceaccountuser
showwelcome
showprogress
allowjumps
navigationdelay
nokeyboard
alloweditaftercompletion
googleanalyticsstyle
googleanalyticsapikey
surveyls_survey_id
surveyls_language
surveyls_title
surveyls_description
surveyls_welcometext
surveyls_endtext
surveyls_url
surveyls_urldescription
surveyls_email_invite_subj
surveyls_email_invite
surveyls_email_remind_subj
surveyls_email_remind
surveyls_email_register_subj
surveyls_email_register
surveyls_email_confirm_subj
surveyls_email_confirm
surveyls_dateformat
surveyls_attributecaptions
email_admin_notification_subj
email_admin_notification
email_admin_responses_subj
email_admin_responses
surveyls_numberformat