Skip to content

Commit

Permalink
Fixed issue #05306: Google Map doesn't center on default Lat/Lon
Browse files Browse the repository at this point in the history
Dev Add map reset function - called when map question shown by conditions

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@10673 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Tony Partner committed Aug 10, 2011
1 parent 1b2c1cd commit 8246afd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 21 deletions.
26 changes: 15 additions & 11 deletions group.php
Expand Up @@ -621,7 +621,7 @@ function checkconditions(value, name, type)
$newjava_runonce = true;
$newjava ="";

$newjava .= "\n\tif (((";
$newjava .= "\n\t\tif (((";

}

Expand Down Expand Up @@ -951,15 +951,19 @@ function checkconditions(value, name, type)
if ((isset($oldq) && $oldq != $cd[0]) || !isset($oldq))//End If Statement
{
$endzone = ")))\n";
$endzone .= "\t{\n";
$endzone .= "document.getElementById('question$cd[0]').style.display='';\n";
$endzone .= "document.getElementById('display$cd[0]').value='on';\n";
$endzone .= "\t}\n";
$endzone .= "\telse\n";
$endzone .= "\t{\n";
$endzone .= "document.getElementById('question$cd[0]').style.display='none';\n";
$endzone .= "document.getElementById('display$cd[0]').value='';\n";
$endzone .= "\t}\n";
$endzone .= "\t\t{\n";
$endzone .= "\t\t\tdocument.getElementById('question$cd[0]').style.display='';\n";
$endzone .= "\t\t\tdocument.getElementById('display$cd[0]').value='on';\n";
$endzone .= "\t\t\tif(\$('#question$cd[0] div[id^=\"gmap_canvas\"]').length > 0)\n";
$endzone .= "\t\t\t{\n";
$endzone .= "\t\t\t\tresetMap($cd[0]);\n";
$endzone .= "\t\t\t}\n";
$endzone .= "\t\t}\n";
$endzone .= "\t\telse\n";
$endzone .= "\t\t{\n";
$endzone .= "\t\t\tdocument.getElementById('question$cd[0]').style.display='none';\n";
$endzone .= "\t\t\tdocument.getElementById('display$cd[0]').value='';\n";
$endzone .= "\t\t}\n";
$cqcount++;
}

Expand Down Expand Up @@ -1185,7 +1189,7 @@ function checkconditions(value, name, type)
}

if (isset($java)) {echo $java;}
echo "\n\tdocument.getElementById('runonce').value=1;\n"
echo "\n\t\tdocument.getElementById('runonce').value=1;\n"
. "\t}\n"
."\t//-->\n"
."\t</script>\n\n"; // End checkconditions javascript function
Expand Down
17 changes: 17 additions & 0 deletions scripts/survey_runtime.js
Expand Up @@ -160,6 +160,23 @@ function GMapsInitialize(question,lat,lng) {
return map;
}

function resetMap(qID) {
var question = $('#question'+qID+' input.location').attr('name');
var name = question.substr(0,question.length - 2);
var coordinates = $('#question'+qID+' input.location').attr('value');
var xy = coordinates.split(" ");
var currentMap = gmaps[question];
var marker = gmaps["marker__"+question];
var markerLatLng = new GLatLng(xy[0],xy[1]);
marker.setLatLng(markerLatLng);
var geocoder = new GClientGeocoder();
geocoder.getLocations(markerLatLng,function(response){
parseGeocodeAddress(response,name);
});
currentMap.checkResize();
currentMap.setCenter(markerLatLng);
}

function parseGeocodeAddress(response, name){
var city = '';
var state = '';
Expand Down
24 changes: 14 additions & 10 deletions survey.php
Expand Up @@ -439,7 +439,7 @@ function checkconditions(value, name, type)
$java .= $endzone;
$endzone = "";
$cqcount=1;
$java .= "\n if (((";
$java .= "\n if (((";
}

if (!isset($oldcq) || !$oldcq)
Expand Down Expand Up @@ -673,15 +673,19 @@ function checkconditions(value, name, type)
if ((isset($oldq) && $oldq != $cd[0]) || !isset($oldq))//Close if statement
{
$endzone = ")))\n"
. " {\n"
. " document.getElementById('question$cd[0]').style.display='';\n"
. " document.getElementById('display$cd[0]').value='on';\n"
. " }\n"
. " else\n"
. " {\n"
. " document.getElementById('question$cd[0]').style.display='none';\n"
. " document.getElementById('display$cd[0]').value='';\n"
. " }\n";
. " {\n"
. " document.getElementById('question$cd[0]').style.display='';\n"
. " document.getElementById('display$cd[0]').value='on';\n"
. " if(\$('#question$cd[0] div[id^=\"gmap_canvas\"]').length > 0)\n"
. " {\n"
. " resetMap($cd[0]);\n"
. " }\n"
. " }\n"
. " else\n"
. " {\n"
. " document.getElementById('question$cd[0]').style.display='none';\n"
. " document.getElementById('display$cd[0]').value='';\n"
. " }\n";
$cqcount++;
}
$oldq = $cd[0]; //Update oldq for next loop
Expand Down

0 comments on commit 8246afd

Please sign in to comment.