Using Google Maps with Qualtrics 2 | XM Community
Skip to main content

Hello.


I am trying to include a map question in my survey using the Google Maps APIs. I have used information I found on the Qualtrics Community (https://community.qualtrics.com/custom-code-12/using-google-maps-with-qualtrics-496), which refers to this page for using the Maps JavaScript API and Places API (https://github.com/pkmnct/qualtrics-google-map-lat-long).

I have the Qualtrics requirements (my account is not free), and also the Google Maps requirements (a billing account, a project, an API key, and Maps JavaScript API and Places API enabled).

I followed the instructions on the page mentioned above (https://github.com/pkmnct/qualtrics-google-map-lat-long), and tested the sample code.  I can save the code in my survey question, but when I go to the survey preview, the map does not load.

Please can someone tell me what could be going wrong?
Something in my API key configuration and APIs enabled?
Something with Qualtrics?

I would greatly appreciate your advice and suggestions.

Regards

@Andrés Adiego Use browser developer tools to debug your code maybe throw some console log line t make sure it’s running properly


Hello @dxconnamnguyen

Thank you very much for your reply. Unfortunately I am not a programmer or developer, and I don't know how to handle the console and do that kind of checks. But if you explain me how to do something simple, I can try and tell you the results.

Thanks again for your interest, and I remain attentive if you can give me more indications.

Regards.


Hello again @dxconnamnguyen 

Looking in the browser console I found this message:

Google Maps JavaScript API has been loaded directly without a callback. This is not supported and can lead to race conditions and suboptimal performance. For supported loading patterns please see https://goo.gle/js-api-loading

 

I hope it will provide more information to be able to solve the problem.


Hello community,

I attach a screenshot of the console, with the detected problems. It seems that the problem may be related to the version of the APIs (?)

I appreciate any help to be able to solve it.

Thanks in advance


Hello Community,

I still need help with this problem.

With the code below, the map question was working fine, but after making some changes to the Qualtrics survey appearance, it stopped working.

Can someone explain to me if the changes to the appearance can affect the operation of the codes to load the map question?

 

I am using the "Mountain valleys" theme in the "Look and field" settings, and the "simple" layout. I removed the "Mountain valleys" theme, but it still doesn't work.

I also have the survey available in English and Spanish.

I have this code in the header section:

<script async src="https://maps.googleapis.com/maps/api/js?v=quarterly&key=MY_API_KEY"></script><script src="https://unpkg.com/qualtrics-google-map-lat-long@2.0.1/dist/QualtricsGoogleMap.min.js"></script>.

 

Where it says "MY_API_KEY", I put my key.

 

And this code in the map question:

Qualtrics.SurveyEngine.addOnload(function().

{

/*Place your JavaScript here to execute when the page loads*/.

initGoogleMapsQuestion(this.questionId, this.getQuestionContainer(), {

  // Map Options, set these! See Map Options in Option Documentation Section

  options: {

    center: {

      lat: -46.05,

      lng: -72.1833333333,

    },

    zoom: 9,

  },

  // Marker Options, set these!

  markers:

    // First Marker

    {

      // See Marker Options in Option Documentation Section

      options: {

        title: "Marker 1",

        draggable: true,

        label: "1",

      },

    },

  ],

});

});

 

I remain attentive to your comments.

Thanks!

 


Simple layout doesn’t support everything and often uses different classes/ids, your script was probably not built to support it.

See more at https://www.qualtrics.com/support/survey-platform/survey-module/look-feel/simple-layout/#CurrentlyUnsupported


Hello @vgayraud 

Yes, the "Simple" layout prevents the code from executing properly. With the rest of the loyouts it works fine.

Thank you.


Hello,

I am also using Google maps API for my survey on Qualtrics. I fixed my previous codes yesterday (Nov 14, 2023) based on this topic and replies included. It worked well yesterday.

But after one night, my maps cannot load successfully. I think maybe the Qualtrics team upgraded the UI settings again? but I have confirmed I did not use the “simple” layout. 

For the header section, I used the code as mentioned in this topic:

<script async src="https://maps.googleapis.com/maps/api/js?v=quarterly&key=MY_API_KEY"></script><script src="https://unpkg.com/qualtrics-google-map-lat-long@2.0.1/dist/QualtricsGoogleMap.min.js"></script>.

This survey is for my dissertation research, so this will be a very pressing issue. I will really appreciate that if someone could help me! I will also try to contact Qualtrics Support but because it is a custom code problem, it might be very hard to ask for help from them. 

Thank you!

 

 


Leave a Reply