Hi,
I am building a Wix website and I want to use a leafletjs map inside.
The map will represents the French departments delimited with polygons as in the example below.
To do this, I need to use a “large” GeoJson file (3.79 MB) in which each department contains between 1000 and 2000 coordinates and there are 96 departments.
To use it in Wix, I need to create a HTML element and communicate with it through the backend, the JS page code and the
$w(“#html1”).postMessage method.
Let’s move on to the code.
departments.jsw
var departmentsData = {"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Polygon", "coordinates": [[[4.78021, 46.17668], [4.78024, 46.18905][....]{"code": "01", "nom": "Ain"}}, {...}; // very large
export function getDepartments() {
return departmentsData;
}
Code for my Page
import {getDepartments} from 'backend/departments';
$w.onReady(function () {
getDepartments().then((departments) => {
console.log("send departments");
$w("#html1").postMessage(departments);
});
});
Code for the HTML element #html1 (shortened here)
<html>
window.onmessage =
function(event) {
if (event.data) {
console.log(event.data);
};
<html>
This is causing a
Uncaught (in promise) Error: Bad Gateway
at s (wixCodeNamespacesAndElementorySupport.min.js:4)
at XMLHttpRequest.n.onreadystatechange (wixCodeNamespacesAndElementorySupport.min.js:4)
at XMLHttpRequest.o (raven.js:375)
I tested the same code with the French regions (4 times smaller) and the code works (the HTML element receives the json).
So, is there a time or size limit to make the request? Is there a solution?
Thank you very much for any help you may have!