Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to lay a grid over a map?

  • YoGL11
  • YoGL11's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 1 week ago #251238 by YoGL11
How to lay a grid over a map? was created by YoGL11
Please help us help you and fill where relevant:
Your LimeSurvey version: LimeSurvey Version 5.6.38
Own server or LimeSurvey hosting: LimeSurvey hosting
Survey theme/template:
==================
Hello,
I have the following situation:
Respondents indicate which city they live in (there are only 13 cities to choose from). Based on that, a map should be shown positioned on that city. How can I do that automatically?
This is how I do it now: for every city I have a question of type 'free short text' and at location I set OpenStreetMap at Use Mapping Service. A map is shown of the city the respondent indicated earlier in the survey (I fill in latitude and longitude of that specific city at 'Default position'). But is there a way to fill in latitude and longitude automatically (so I only need 1 question of type 'free short text' and location OpenStreetMap)?
Secondly, I want to lay a grid over that map showing the neighborhoods/districts of that city. Is that possible? How do I do that? I have a GEOJSN file with all the neighborhoods/districts of different cities (more than those 13 cities). How do I link this to the question with the map? I know this can be done via a Javascript, but I can't find how to do this. Can anyone help me? How can I show the correct grid?

Thanks in advance!

Please Log in to join the conversation.

  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 6 days ago #251372 by Joffm
Replied by Joffm on topic How to lay a grid over a map?
To answer your first question:
Use a question of type equation where you set the lat and long of the selected city. I suppose it is a single punch question.
Equation question "coord"
{if(city==1,'50.22222 8.12345',if(city==2,'45.3456 12.2345',if(city==3,....

Then you enter {coord} in "default position".

The second question? I do not understand your goal. Can you show something?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 months 5 days ago #251378 by tpartner
Replied by tpartner on topic How to lay a grid over a map?
Regarding the GeoJSON layer, I'm not sure you can add that after map initialization. You may need to insert a custom map via JavaScript.

Some inspiration:

- leafletjs.com/examples/geojson/
- codepen.io/pmckinney/pen/mELyNY

Cheers,
Tony Partner

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

Please Log in to join the conversation.

  • YoGL11
  • YoGL11's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 months 4 days ago #251404 by YoGL11
Replied by YoGL11 on topic How to lay a grid over a map?
Dear Joffm,

I tried your solution with coord and it works! Thank you very much!
The second question: We show in a further question the neighborhoods/districts of that city and with the overlay of neighborhoods/districts on the map, the respondents can see in which neighborhoods/district their street is situated. And that is what we are interested in. How can I do that? I have a GEOJSN file, but is that the way to do this? Is there another (easier) way to do that?

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose