Welcome, Guest
Username: Password: Remember me

TOPIC: Borders issues

Borders issues 2 months 4 weeks ago #107908

  • pievarolil
  • pievarolil's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
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 administrator has disabled public write access.

Borders issues 2 months 3 weeks ago #107992

  • pievarolil
  • pievarolil's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 7
  • Karma: 0
Was my question unclear or just too difficult to answer?

Cheers,
Liliana
The administrator has disabled public write access.

Borders issues 2 months 3 weeks ago #108000

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4049
  • Thank you received: 739
  • Karma: 341
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:
// 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:
// 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.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
The following user(s) said Thank You: pievarolil
Moderators: ITEd
Time to create page: 0.141 seconds
Donation Image