cameron1138 Posted May 13, 2021 Share Posted May 13, 2021 Sorry if this is a stupid question but I couldn't find an answer anywhere. I'm setting up a website and I'm experimenting with a Google map with Javascript. I know that I need a Business plan or higher in order for Javascript to run on the public site, but I'm wondering if that's also required for it to run on the private demo (obviously can't share a link)? The initial setup page said that I could build the site with the features I needed and then purchase whatever plan allowed for everything I'd included, so that makes me think the script should work in the preview. I just want to know whether my code isn't showing up because of a problem with the code or because I don't have a Business plan yet. (I'm creating it for a client and I don't want to have him purchase the plan until I know for sure that we need it, and I don't know if this is how I'll ultimately end up doing the map or not.) Link to comment
Beyondspace Posted May 13, 2021 Share Posted May 13, 2021 (edited) 54 minutes ago, cameron1138 said: Sorry if this is a stupid question but I couldn't find an answer anywhere. I'm setting up a website and I'm experimenting with a Google map with Javascript. I know that I need a Business plan or higher in order for Javascript to run on the public site, but I'm wondering if that's also required for it to run on the private demo (obviously can't share a link)? The initial setup page said that I could build the site with the features I needed and then purchase whatever plan allowed for everything I'd included, so that makes me think the script should work in the preview. I just want to know whether my code isn't showing up because of a problem with the code or because I don't have a Business plan yet. (I'm creating it for a client and I don't want to have him purchase the plan until I know for sure that we need it, and I don't know if this is how I'll ultimately end up doing the map or not.) You can use javascript on trail mode, but the script will be disabled in editor (even after purchase). Save the page content and preview it other window Edited May 13, 2021 by bangank36 BeyondSpace - Squarespace Website Developer 🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox) 🗓️ Delivery Date Picker (Squarespace Date format) 💫 Animated Buttons (Referral URL) 🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations) 🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates) If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you! Link to comment
creedon Posted May 13, 2021 Share Posted May 13, 2021 Quote obviously can't share a link You can share a link if you set up a site-wide password. Post the password here. Adding a site-wide password is not a security breach. Please read the documentation at the link provided to understand how it works. We can then take a look at your issue. Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
cameron1138 Posted May 18, 2021 Author Share Posted May 18, 2021 (edited) Alright, here's the link. The password is 'bielbypreview'. There's currently a regular embedded Google map on the page, but the custom map I created should be displaying below it. Edited May 18, 2021 by cameron1138 Link to comment
creedon Posted May 18, 2021 Share Posted May 18, 2021 (edited) After some quick research it appears you are running into a Content Security Policy (CSP) issue. Here part of what I saw in the browser looking at your site. Here is some reading. google maps api script does load due to content security policy Example Using Google Maps with a Content-Security-Policy Content Security Policy - meta tag That last one is important to note. That may be the way to solve the issue. Put a meta tag in Settings > Advanced > Code Injection > HEADER with the proper incantation in it! 😀 If you remove the custom map code, make a copy somewhere, we can verify if the CSP issue goes away. It is probably the map code causing the issue but you never know. It could be something else. Edited May 18, 2021 by creedon Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
cameron1138 Posted May 19, 2021 Author Share Posted May 19, 2021 21 hours ago, creedon said: After some quick research it appears you are running into a Content Security Policy (CSP) issue. Here part of what I saw in the browser looking at your site. Here is some reading. google maps api script does load due to content security policy Example Using Google Maps with a Content-Security-Policy Content Security Policy - meta tag That last one is important to note. That may be the way to solve the issue. Put a meta tag in Settings > Advanced > Code Injection > HEADER with the proper incantation in it! 😀 If you remove the custom map code, make a copy somewhere, we can verify if the CSP issue goes away. It is probably the map code causing the issue but you never know. It could be something else. This looks like it could be it. Where were you finding that error message? I'm not seeing any about CSP in the console so I won't know where to look to check if removing the map code makes it go away. If I can determine that that's causing the problem I'll work on messing with the header meta tag until I get it working. Link to comment
creedon Posted May 19, 2021 Share Posted May 19, 2021 It was in the console but the page is not displaying the error now. It appears you altered the page? Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
cameron1138 Posted May 20, 2021 Author Share Posted May 20, 2021 (edited) 20 hours ago, creedon said: It was in the console but the page is not displaying the error now. It appears you altered the page? I did, I added a CSP meta tag to the header. I also replaced my personal API key with the one Squarespace uses and added in a brief bit of code to print 'test text' to the console to check whether any of the Javascript on the page was running at all, and that part worked, just not the map. Edited May 20, 2021 by cameron1138 Link to comment
cameron1138 Posted May 21, 2021 Author Share Posted May 21, 2021 I think I figured it out, it was just a little dumb mistake. I added console.log statements to the code to see what was running and all the functions were being called as if the map was being created, and I realized I'd forgotten to paste in the CSS with the dimensions of the map div, so I guess the map was there, just with a size of 0 x 0. I've got it working now. creedon 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment