Answer the question
In order to leave comments, you need to log in
Why does an error pop up inside the osmtogeojson library when using it in preload (Electron)?
preload.js code:
const Request = require('request-promise');
const OSMToGeoJSON = require('osmtogeojson');
const DOMParser = require('xmldom').DOMParser;
const Log = console.log;
Request({
method: 'GET',
uri: 'https://api.openstreetmap.org/api/0.6/map?bbox=53.97501,57.05107,53.97616,57.05166',
encoding: 'utf8'
}).then(function (xml_osm) {
var xml_parser = new DOMParser();
var xml = xml_parser.parseFromString(xml_osm);
var geojson = OSMToGeoJSON(xml);
var json_geojson = JSON.stringify(geojson);
Log(json_geojson);
}).catch(function (err) {
Log(err);
});
const {app, BrowserWindow} = require('electron')
const path = require('path')
function createWindow () {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
//nodeIntegration:true
}
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
// Open the DevTools.
mainWindow.webContents.openDevTools()
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question