Welcome to the LimeSurvey Community Forum

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

Borders issues

  • pievarolil
  • pievarolil's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #107908 by pievarolil
Borders issues was created by pievarolil
Hi everyone,

Having the ability to geocode data at the input stage is great. So I like the Text questions - Short free text (use mapping service)field type in LimeSurvey. However, my organization is very worried about borders and how we represent disputed areas.

Therefore, I have two questions:
- Can we use the Google maps API and disable the borders layer (for all our surveys in our server)?
If so, how?
- Can we have our own mapping service? We have an ESRI ArcGIS server with the national borders.
If so, how complex is to do this?

Thanks!
Liliana
The topic has been locked.
  • pievarolil
  • pievarolil's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
9 years 10 months ago #107992 by pievarolil
Replied by pievarolil on topic Borders issues
Was my question unclear or just too difficult to answer?

Cheers,
Liliana
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
9 years 10 months ago #108000 by tpartner
Replied by tpartner on topic Borders issues

Can we use the Google maps API and disable the borders layer (for all our surveys in our server)?
If so, how?

Yes, you can override the LimeSurvey GMapsInitialize() function to add your custom styles for all maps.

Placing this at the end of template.js will override that function and remove all country borders:
Code:
// Override the built-in Google map function to add styles for all maps
function GMapsInitialize(question,lat,lng) {
 
  var name = question.substr(0,question.length - 2);
  var latlng = new google.maps.LatLng(lat, lng);
 
  // New styles
  var styleArray = [
    {
      featureType: "administrative.country",
      elementType: "geometry.stroke",
      stylers: [
        { visibility: "off" } // No country borders
      ]
    }
  ];  
 
  var mapOptions = {
    zoom: zoom[name],
    styles: styleArray,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
 
  var map = new google.maps.Map(document.getElementById("gmap_canvas_" + question), mapOptions);
  gmaps[''+question] = map;
 
  var marker = new google.maps.Marker({
    position: latlng,
    draggable:true,
    map: map,
    id: 'marker__'+question
  });
  gmaps['marker__'+question] = marker;
 
  google.maps.event.addListener(map, 'rightclick', function(event) {
    marker.setPosition(event.latLng);
    map.panTo(event.latLng);
    geocodeAddress(name, event.latLng);
    $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
  });
 
  google.maps.event.addListener(marker, 'dragend', function(event) {
    //map.panTo(event.latLng);
    geocodeAddress(name, event.latLng);
    $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
  });
}

This will remove country and provincial borders:
Code:
// Override the built-in Google map function to add styles for all maps
function GMapsInitialize(question,lat,lng) {
 
  var name = question.substr(0,question.length - 2);
  var latlng = new google.maps.LatLng(lat, lng);
 
  // New styles
  var styleArray = [
    {
      featureType: "administrative.country",
      elementType: "geometry.stroke",
      stylers: [
        { visibility: "off" } // No country borders
      ]
    },
    {
      featureType: "administrative.province",
      elementType: "geometry.stroke",
      stylers: [
        //{ visibility: "off" } // No provincial borders
      ]
    }
  ];  
 
  var mapOptions = {
    zoom: zoom[name],
    styles: styleArray,
    center: latlng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
 
  var map = new google.maps.Map(document.getElementById("gmap_canvas_" + question), mapOptions);
  gmaps[''+question] = map;
 
  var marker = new google.maps.Marker({
    position: latlng,
    draggable:true,
    map: map,
    id: 'marker__'+question
  });
  gmaps['marker__'+question] = marker;
 
  google.maps.event.addListener(map, 'rightclick', function(event) {
    marker.setPosition(event.latLng);
    map.panTo(event.latLng);
    geocodeAddress(name, event.latLng);
    $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
  });
 
  google.maps.event.addListener(marker, 'dragend', function(event) {
    //map.panTo(event.latLng);
    geocodeAddress(name, event.latLng);
    $("#answer"+question).val(Math.round(event.latLng.lat()*10000)/10000 + " " + Math.round(event.latLng.lng()*10000)/10000);
  });
}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: pievarolil
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose