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);
});
}