Ability to add Google Maps as a question

Plus d'informations
il y a 5 ans 1 mois #100840 par mfpereira
mfpereira a répondu au sujet : Ability to add Google Maps as a question
Any new about how put a search box in google maps?

I find some code in google developers

developers.google.com/maps/documentation...les/places-searchbox

I already do same alterations, but I can realize all.

Best regards

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 10 mois #104865 par dweisser
dweisser a répondu au sujet : Ability to add Google Maps as a question
Has anyone tried to calculate driving distances between two points on their survey using this map?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 10 mois #104901 par tpartner
tpartner a répondu au sujet : Ability to add Google Maps as a question
I haven't tried it but you should be able to use the Google Maps API v3 Distance matrix - developers.google.com/maps/documentation...cript/distancematrix


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 10 mois #104905 par Mazi
Mazi a répondu au sujet : Ability to add Google Maps as a question
I have seen similar requests before. So if you succeed in creating a nice solution, please add it to manual -> workarounds.

Thanks!

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com
Want to use your survey offline -> www.offlinesurveys.com

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 10 mois #104915 par dweisser
dweisser a répondu au sujet : Ability to add Google Maps as a question
My problem is the Doctype declaration, I think. :) Google says to use Doctype 5.
I don't know where to put that bit of code.

I assume the head of the template is good for the javascript. You have to register your API key and you can do that under general settings. There is some required CSS - that's an easy one.

Any thoughts?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 9 mois - il y a 4 ans 9 mois #104986 par tpartner
tpartner a répondu au sujet : Ability to add Google Maps as a question
Well, I didn't have much time to spend on this but here's a quick-and-dirty example of how to calculate the distance and travel time from the "Default position" using the Google Maps API v3 Distance matrix .

Place this in the question source.
<script type="text/javascript" charset="utf-8">	
 
	$(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('<div class="distanceResults" />');
 
		});
	});
 
	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]+'<br />\
												End address: '+destinations[j]+'<br />\
												Distance: '+results[j].distance.text+'<br />\
												Time: '+results[j].duration.text+'');
				}
			}
		}
	}
</script>

Demo survey:

Fichier attaché :

Nom du fichier : travel_dis...e_v2.lss
Taille du ficher :15 ko








.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Pièces jointes :
Dernière édition: il y a 4 ans 9 mois par tpartner.
Les utilisateur(s) suivant ont remercié: dglp

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 9 mois #105001 par dweisser
dweisser a répondu au sujet : Ability to add Google Maps as a question
Hey T,
This is great. I think there are a lot of directions one could go here.

I was working on this, but instead of using the short-text Map-style question, I ended up showing a map inside a short-text text-style question. It is not optimal because the style requirements were pretty hard to work with, however I was able to save the calculated distance as the question's answer.

I assume that this is what this does:
// Insert the results element
$(answerInput).after('<div class="distanceResults" />');

I suppose the "benefit" of using the external map rather than the short-text map-style question is that it might be more easy to implement driving directions, location search and things of that nature. Or is it?

Your solution is really great. Thank you as always for relentlessly adding to the knowledge base.

David

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 9 mois #105002 par tpartner
tpartner a répondu au sujet : Ability to add Google Maps as a question
Yes, of course, this could be applied to any map. I just used the LimeSurvey map because it was faster.



.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 4 mois #111398 par AudioMan612
AudioMan612 a répondu au sujet : Ability to add Google Maps as a question
Hi,

As some people have mentioned here, I would like a way to implement a search function in Google Maps in a survey. I have very limited experience with web development, so I'm struggling a bit with this (I'm used to writing stand-alone programs, not scripts for webpages). Anyways, I found a LimeSurvey that has successfully implemented a search function and I was wondering if anyone might have any clues as to how to implement this.

bart.etcsurvey.com/index.php/

The first question with Google Maps is somewhere around 7 questions in. The survey remembers your choice as the origin of you trip and shows it on a map later on. I'm currently going through the sources for the webpage trying to see if I get any ideas, but any help would be awesome. Thanks!

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 4 ans 1 mois #113715 par s9521070
s9521070 a répondu au sujet : Ability to add Google Maps as a question
Did anyone find a way to include a "Place search box" inside a question that uses Google Maps? It would be really helpful if the functionality shown here can be used to obtain the latitude-longitude values from a Google Maps Limesurvey question without the necessity to move around the map manually.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 11 mois #129629 par Maryam01
Maryam01 a répondu au sujet : Ability to add Google Maps as a question
Is there a way to add the google search bar in the version 2.06?

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 11 mois #129633 par tpartner
tpartner a répondu au sujet : Ability to add Google Maps as a question
Can you explain more? Add a search bar to what?

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 11 mois #129635 par Maryam01
Maryam01 a répondu au sujet : Ability to add Google Maps as a question
Thank you for your prompt reply.

What we mean is to have a search bar that will allow survey participant to enter their location and the map will show the specific location in google map.

Right now we use a short text question and enable the google map but the survey participant will need to drag the map to go to his/her location which consume a lot of time unlike if you have a search bar you will just type your address and your location will be display.

Thnaks a lot
Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 11 mois #129648 par tpartner
tpartner a répondu au sujet : Ability to add Google Maps as a question
LimeSurvey uses Google Maps API v3 so, as stated earlier in this thread, the Google Bar (search bar) doesn't exist. You will need to do the search with an AJAX call to the Google Places API - developers.google.com/places/?csw=1

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 2 ans 10 mois #130480 par dsvo
dsvo a répondu au sujet : Ability to add Google Maps as a question
hello, .i am trying to do a survey for my master thesis..

is it easy to explain me how to add a search box in a question with google maps so i can type my adress and my location be displayed..? i am new here and i dont have so much knowledge...

Connexion ou Créer un compte pour participer à la conversation.

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!