GithubHelp home page GithubHelp logo

Comments (11)

francois2metz avatar francois2metz commented on August 20, 2024

Hi @ArthurSalomaoo,
The file you are sending on this sample code is empty, without any features. If your geojson features are in the mapa.geojson file, you should load/fetch it before sending it to the remote API. You can send an URL and indoorequal will load it.
There a remote tester https://indoorequal.org/remote.html. Try putting the URL of your gist in the "Open preview with URL": https://gist.githubusercontent.com/ArthurSalomaoo/54a78604c9edd11d196f70b7c551f223/raw/7d6c346bdb1b882bfdca66c7dabaa68176caca33/mapa.geojson

from indoorequal.org.

marmundo avatar marmundo commented on August 20, 2024

HI @francois2metz. I'm his advisor.

On remote tester it works properly. However, using indoor documentation example

<script>
    const indoorEqualWindow = window.open("https://indoorequal.org/");
window.addEventListener('message', (e) => {
  if (e.data.event === 'ready') {
    const file = new File([JSON.stringify({type: 'FeatureCollection', features: []})], 'mapa.geojson');
    indoorEqualWindow.postMessage({ command: 'preview',file }, '*');
  }
});
</script>

Specifically on indoorEqualWindow.postMessage({ command: 'preview',file }, '*'); indoor equal doesn't load my geojson.

I've console.log(file) object and I can see file content.

What do you suggest to fix this code and load this geojson file using postMessage method?

Thanks.

from indoorequal.org.

francois2metz avatar francois2metz commented on August 20, 2024

I've console.log(file) object and I can see file content.

Which file content do you see? {type: 'FeatureCollection', features: []}) is an empty geojson. It cannnot render anything.

What do you suggest to fix this code and load this geojson file using postMessage method?

You could "fetch" the geojson content and put it in the file before sending it to indoorequal.

from indoorequal.org.

ArthurSalomaoo avatar ArthurSalomaoo commented on August 20, 2024

I've console.log(file) object and I can see file content.

Which file content do you see? {type: 'FeatureCollection', features: []}) is an empty geojson. It cannnot render anything.

What do you suggest to fix this code and load this geojson file using postMessage method?

You could "fetch" the geojson content and put it in the file before sending it to indoorequal.

Hi @francois2metz

Look what I did. I checked file size below. Unfortunatelly, indoorequal does not render it.
Could you see my code and suggest a solution to it.

The indoor map is to this location link

<body>
  <input type="file" onchange="showFile(this)">

</body>
<script>
  let arquivo = null

  let indoorEqualWindow = null

  function showFile(input) {

    arquivo = input.files[0];
    let reader = new FileReader();

    reader.readAsText(arquivo);

    reader.onload = function () {
      arquivoContent = reader.result
      
      const arquivo = new File([JSON.stringify(arquivoContent)], 'mapa.geojson');
 
    };

    reader.onerror = function () {
      console.log(reader.error);
    };
    indoorEqualWindow = window.open("https://indoorequal.org/");
  
  }

  window.addEventListener('message', (e) => {

    if (e.data.event === 'ready') {
    

      alert('FILE SIZE>>>'+arquivo.size)
      indoorEqualWindow.postMessage({ command: 'preview', arquivo }, '*');
     
    }
  });

Thanks.

In future, I can contribute to docummentation adding more examples.

from indoorequal.org.

francois2metz avatar francois2metz commented on August 20, 2024
<body>
  <input type="file" onchange="showFile(this)">

</body>
<script>
  let arquivo = null

  let indoorEqualWindow = null

  function showFile(input) {

    arquivo = input.files[0];
    let reader = new FileReader();

    reader.readAsText(arquivo);

    reader.onload = function () {
      arquivoContent = reader.result
      
      const arquivo = new File([JSON.stringify(arquivoContent)], 'mapa.geojson');

You declare a new const here that is scoped to the function. You should at least remove the const.

};

reader.onerror = function () {
  console.log(reader.error);
};
indoorEqualWindow = window.open("https://indoorequal.org/");

}

window.addEventListener('message', (e) => {

if (e.data.event === 'ready') {


  alert('FILE SIZE>>>'+arquivo.size)
  indoorEqualWindow.postMessage({ command: 'preview', arquivo }, '*');

The second parameter of the preview command must be named file, not arquivo

}

});

I commented a few obvious problems. There is probably a timing issue between the onload of the reader and the listening of the 'ready' event from indoorequal.

from indoorequal.org.

francois2metz avatar francois2metz commented on August 20, 2024

@ArthurSalomaoo Did you make some progress? As this is not an indoor= issue I'm closing this. Feel free to open a discussion that I enabled: https://github.com/orgs/indoorequal/discussions

from indoorequal.org.

marmundo avatar marmundo commented on August 20, 2024

@ArthurSalomaoo Did you make some progress? As this is not an indoor= issue I'm closing this. Feel free to open a discussion that I enabled: https://github.com/orgs/indoorequal/discussions

Hi @francois2metz, we didn't make it. We are cloning your code and hoisting it and trying to render our geojson.

Thanks for your support! We'll send news about our advances.

from indoorequal.org.

francois2metz avatar francois2metz commented on August 20, 2024

Here is a working version: https://jsfiddle.net/2x5m6yuz/

from indoorequal.org.

marmundo avatar marmundo commented on August 20, 2024

Here is a working version: https://jsfiddle.net/2x5m6yuz/

Thanks. I’ll open a discuss to discuss with you to evaluate if indoorequal is a viable option to our research project.

from indoorequal.org.

ArthurSalomaoo avatar ArthurSalomaoo commented on August 20, 2024

Hello, @francois2metz , I would like to ask you a question about using Indoorequal. Could we start a discussion?

from indoorequal.org.

francois2metz avatar francois2metz commented on August 20, 2024

Hello, @francois2metz , I would like to ask you a question about using Indoorequal. Could we start a discussion?

Sure

from indoorequal.org.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.