diff --git a/js/authoring/controllers/tabs/contextTabController.js b/js/authoring/controllers/tabs/contextTabController.js index 0c8e65c66f133d4a4c5fd2eaf497348c0a37a3c9..00a3e74506642b69a1443c8be22e1c1aaf6e7db1 100644 --- a/js/authoring/controllers/tabs/contextTabController.js +++ b/js/authoring/controllers/tabs/contextTabController.js @@ -530,9 +530,6 @@ function fillParameterSelection(cp) { if (chosenValue != "") { var latlng = new google.maps.LatLng(lat, long); replaceMarker(latlng); - // center the map and set zoom factor - map.setCenter(latlng); - map.setOptions({zoom: 15}); } // in any case where coordinates are expected @@ -741,30 +738,25 @@ function getParameterInput(val, num) { /* get values from inputs and set the marker on this point in google maps */ // TODO: if ... coordinates expected - var lat, long; - var lngInputDiv = $("#divMaps").prev(); - var latInputDiv = $(lngInputDiv).prev(); + if ($("#divContextParameter").find("#divMaps").length > 0) { - // check if latitude is not empty - if ($("#inputContextParameter1").val()) { - lat = $(latInputDiv).children("input")[0].value; - } + var lat, long; + var lngInputDiv = $("#divMaps").prev(); + var latInputDiv = $(lngInputDiv).prev(); - // check if longitude is not empty - if ($("#inputContextParameter2").val()) { - long = $("#inputContextParameter2").val(); - } + // check if latitude is not empty + lat = $(latInputDiv).children("input")[0].value; - // only if both inputs have a value set marker - if ($("#inputContextParameter1").val() && $("#inputContextParameter2").val()) { - var new_LatLong = new google.maps.LatLng(lat, long); + // check if longitude is not empty + long = $(lngInputDiv).children("input")[0].value; - // replace old marker and set the new one - replaceMarker(new_LatLong); + // only if both inputs have a value set marker + if (lat && long) { + var new_LatLong = new google.maps.LatLng(lat, long); - // center the map and set zoom factor - map.setCenter(new_LatLong); - map.setOptions({zoom: 15}); + // replace old marker and set the new one + replaceMarker(new_LatLong); + } } } diff --git a/js/authoring/controllers/tabs/locationInfoMapViewController.js b/js/authoring/controllers/tabs/locationInfoMapViewController.js index bd592b88b9c9bb5f6de8c85a126ec83f70edae34..bd1fe81e049af2bf7135472bfc8545d7b702f07b 100644 --- a/js/authoring/controllers/tabs/locationInfoMapViewController.js +++ b/js/authoring/controllers/tabs/locationInfoMapViewController.js @@ -346,4 +346,8 @@ function replaceMarker(location) { icon: image, shadow: shadow }); + + // center the map and set zoom factor + map.setCenter(location); + map.setOptions({zoom: 15}); } \ No newline at end of file