- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Ability to add Google Maps as a question
- gacquier
- Topic Author
- Offline
- New Member
Less
More
11 years 8 months ago #83671
by gacquier
Replied by gacquier on topic Ability to add Google Maps as a question
Our installation was on Version 1.91RC6 Build 9986...
Not sure if it's the same solution in later versions...
Not sure if it's the same solution in later versions...
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
11 years 8 months ago - 11 years 8 months ago #83683
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Ability to add Google Maps as a question
As far as I know, for V3 of the maps API, there is no googleBar available.
Some insight here - code.google.com/p/gmaps-api-v3-googlebar/
Some insight here - code.google.com/p/gmaps-api-v3-googlebar/
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 11 years 8 months ago by tpartner.
The topic has been locked.
- mfpereira
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 2 weeks ago #94561
by mfpereira
Replied by mfpereira on topic Ability to add Google Maps as a question
I have the same problem.
I don't find the line.
Thanks
I don't find the line.
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
11 years 2 weeks ago #94572
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Ability to add Google Maps as a question
As mentioned, this is not available with V3 of the maps API.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- mfpereira
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
11 years 1 week ago #94681
by mfpereira
Replied by mfpereira on topic Ability to add Google Maps as a question
Ok sorry.
So I can't add that option to my survey?
If a could switch the information from lat and long to the zip code it would be useful.
Do you know how I can do that?
Many thanks
So I can't add that option to my survey?
If a could switch the information from lat and long to the zip code it would be useful.
Do you know how I can do that?
Many thanks
The topic has been locked.
- mfpereira
- Offline
- New Member
Less
More
- Posts: 3
- Thank you received: 0
10 years 6 months ago #100840
by mfpereira
Replied by mfpereira on topic 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
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
The topic has been locked.
- dweisser
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
10 years 2 months ago #104865
by dweisser
Replied by dweisser on topic Ability to add Google Maps as a question
Has anyone tried to calculate driving distances between two points on their survey using this map?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
10 years 2 months ago #104901
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic 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.
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
10 years 2 months ago #104905
by Mazi
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
Replied by Mazi on topic 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!
Thanks!
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
- dweisser
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
10 years 2 months ago #104915
by dweisser
Replied by dweisser on topic 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?
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?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
10 years 2 months ago - 10 years 2 months ago #104986
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic 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.
Demo survey:
.
Place this in the question source.
Code:
<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:
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
Last edit: 10 years 2 months ago by tpartner.
The following user(s) said Thank You: dglp
The topic has been locked.
- dweisser
- Offline
- Premium Member
Less
More
- Posts: 115
- Thank you received: 4
10 years 2 months ago #105001
by dweisser
Replied by dweisser on topic 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:
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
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:
Code:
// 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
The topic has been locked.