Javascript not working on Loop & Merge | XM Community
Skip to main content

Hi, I have been working with a survey that has a Javascript script that displays a Google Maps and collect the coordinates of the location, but once I have applied a loop and merge on the question it, the map stopped appearing anymore.
Here is a picture of how it looks when it is outside de Loop & Merge
2.PNG
And this is in the Loop & Merge
1.PNG
Here is the code I am using:

Qualtrics.SurveyEngine.addOnload(function()
{
initGoogleMapsQuestion(this.questionId, this.getQuestionContainer(), {
 // Map Options, set these! See Map Options in Option Documentation Section
 options: {
   center: {
     lat: 47.377749,
     lng: 8.540780,   
   },
   zoom: 10,
 },
 // Marker Options, set these!
 markers: ,
   // First Marker
   {
     // See Marker Options in Option Documentation Section
     options: {
       title: "Location",
       draggable: true,
       label: "1",
     },
     autocomplete: {
       // If true, an autocomplete will show.
       enabled: true,
       // The label shown for the autocomplete field
       label: "Residence location",
       // Styles for the label
       labelCss: "padding-left: 0; padding-right: 0;",
       // Text to show if an invalid location is selected
       invalidLocationAlertText:
         "Please choose a location from the search dropdown. If your location doesn't appear in the search, enter a nearby location and move the marker to the correct location.",
     },
   },

 ],
});
});

Qualtrics.SurveyEngine.addOnReady(function()
{
   /*Place your JavaScript here to run when the page is fully displayed*/

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
   /*Place your JavaScript here to run when the page is unloaded*/

});


Try replacing:
initGoogleMapsQuestion(this.questionId,...
with:
initGoogleMapsQuestion("${lm://CurrentLoopNumber}_"+this.questionId,...


Thanks for your answer, but the change you proposed didn't work.


Leave a Reply