Apache ECharts map weird (very basic question) - echarts

Hi have some trouble getting started with the following code:
<html>
<head>
<script src="https://echarts.apache.org/examples/vendors/echarts/echarts.min.js?_v_=1574102238076"></script>
<script src="https://echarts.apache.org/examples/vendors/echarts/map/js/world.js?_v_=1574102238076"></script>
</head>
<body>
<div id="eChartVersionIt_33_0" style="height: 535px; width: 935px;" ></div>
<script>
function distrLocaEu(container, commandName) {
var myChart = echarts.init(document.getElementById(container));
option = {
backgroundColor: '#111',
geo: {
map: 'world',
},
}
myChart.setOption(option);
};
distrLocaEu('eChartVersionIt_33_0','ChartDistrLocaEu');
</script>
</body>
</html>
This should render an empty map of the world.
Indeed, copy/pasting it in JsFiddle works correctly.
If I put in a normal HTML file, both Firefox and Chrome show up a VERY corrupted world
Am I missing something very stupid?

figured it out. I was referring the libs using https while in dev mode (http)

Related

Embedded Vega is missing tooltips

I have the following JSFiddle, demonstrating a small Vega Bar chart:
<head>
<script src="https://cdn.jsdelivr.net/npm/vega#5"></script>
</head>
<body>
<div id="view"></div>
<script type="text/javascript">
var view;
var chart = { Vega code removed for brevity - please check JSFiddle}
render(chart);
function render(spec) {
view = new vega.View(vega.parse(spec), {
renderer: 'canvas', // renderer (canvas or svg)
container: '#view', // parent DOM container
hover: true // enable hover processing
});
return view.runAsync();
}
</script>
</body>
If you copy the vega object into Vega Editor you get a tooltip when hovering over the chart elements.
Within the JSFiddle there is no tooltip.
Could someone please help me get a tooltip in the HTML-embedded version?
I have been able to get the full functionality through using vega-embed with versions listed below:
<!DOCTYPE html>
<html>
<head>
<script src="vega-5.17.3.min.js"></script>
<script src="vega-lite-4.17.0.min.js"></script>
<script src="vega-embed-6.15.0.min.js"></script>
</head>
<body>
<div id="vis"></div>
<script type="text/javascript">
var spec = { Vega code removed for brevity - please check JSFiddle}
vegaEmbed('#vis', spec).then(function(result) {
}).catch(console.error);
</script>
</body>
</html>

Using WYSIWYG editor like summernote in openui5 application

I am fairly new to openui5. I want to include summernote editor into my application. I have included the cdn links from their homepage but I am getting the following error
ShellRenderer-dbg.js:143 Uncaught (in promise) TypeError: Cannot read property 'require' of undefined
at Object.S.getLogoImageHtml (ShellRenderer-dbg.js:143)
at Object.S.render (ShellRenderer-dbg.js:86)
at R.renderControl (RenderManager-dbg.js:1004)
at R.render (RenderManager-dbg.js:1259)
at constructor.U.rerender (UIArea-dbg.js:629)
at constructor.Core.renderPendingUIUpdates (Core-dbg.js:2774)
at constructor.Core.init (Core-dbg.js:1235)
at Core-dbg.js:485
at a (Core-dbg.js:179)
at SyncPoint.finishTask (Core-dbg.js:173)
Any ideas would be much appreciated. Thanks
I've managed to get this working in a simple scenario but not sure how it will work with other UI5 elements & re-rendering etc. I've created a simple control to show how it could interact with UI5 but it would need some work!
Notes: SAPUI5 contains jQuery in the default library, although there is a non-jQuery version available so you can use your own version of jQuery, I am not sure of the version needed to get both working optimally overlap. Additionally, Summernote seems to require bootstrap CSS + JS and not sure if that will work with UI5 too, especially if this is to be deployed in a Launchpad scenario. Could be OK as a standalone app though!
Have fun!
sap.ui.define([
"sap/ui/core/Control"
], function (Control) {
"use strict";
return Control.extend("MySummernoteControl", {
metadata: {
properties: {},
aggregations: {},
events: {}
},
renderer: {
apiVersion: 2,
render: function(rm, oButton) {
rm.openStart("div", oButton);
rm.openEnd();
rm.close("div");
}
},
onAfterRendering: function () {
if (!this._rendered) {
this.$().summernote();
this._rendered = true;
}
}
});
});
const ctrl = new MySummernoteControl();
ctrl.placeAt("content");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-theme="sap_fiori_3"
data-sap-ui-xx-bindingSyntax="complex"
data-sap-ui-libs="sap.m"></script>
<!-- include bootstrap -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!-- include summernote css/js -->
<link href="https://cdn.jsdelivr.net/npm/summernote#0.8.18/dist/summernote.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/summernote#0.8.18/dist/summernote.js"></script>
</head>
<body class="sapUiBody sapUiSizeCompact">
<div id='content'></div>
</body>
</html>

Editing feature in OpenLayers2 published by geoserver and saving the updated in postgres connected database table

I have published a shapefile "ind_adm2" in geoserver as Postgis(postgres database), It can be accessed as webpage using OpenLayers code given below. Now I need to edit the shapefile on webpage itself and save the edited(updated) things in Postgres database. Can anyone help !!
I tried using wfs URL of geoserver but unable to select the feature.
<html>
<head>
<script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
basemap = new OpenLayers.Layer.WMS( "Layer Name1",
"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic'} );
utility = new OpenLayers.Layer.WMS( "Layer Name2",
"http://localhost:8080/geoserver/iirs/ows?", {layers: 'iirs:ind_adm2',
transparent:"true"}, {isBaseLayer:false} );
map.addLayers([basemap,utility]);
map.zoomToMaxExtent();
</script>
</body>
</html>
Its expected to select any polygon then edit there itself and update the edits in postgres database.
As what you need will be much more complex than your existing code you should update that to the latest version of OpenLayers (currently 5.3.0) and develop with that. It is easier to get started using the full build https://openlayers.org/en/latest/doc/quickstart.html which is very similar to using versions 3 and 4 so you will be able to reuse examples from those versions. For help about editing WFS here's one question with links a tutorial and some examples Javascript editing WFS from GeoServer using OpenLayers
<html>
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css" type="text/css">
<!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var basemap = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: "http://vmap0.tiles.osgeo.org/wms/vmap0",
params: {
'LAYERS': 'basic'
},
projection: 'EPSG:4326',
ratio: 1
})
});
var utility = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: "http://localhost:8080/geoserver/iirs/ows",
params: {
'LAYERS': 'iirs:ind_adm2',
'TRANSPARENT': 'true'
},
projection: 'EPSG:4326'
})
});
var map = new ol.Map({
target: 'map',
layers: [basemap], utility],
view: new ol.View({
projection: 'EPSG:4326'
})
});
map.getView().fit(map.getView().getProjection().getExtent());
</script>
</body>
</html>

How do I transform nested components in separate jsx files with babel?

I haven't used React in several months, and tonight I was trying to write jsx that is automatically compiled to jsx by babel according to these directions.
I have two files like this:
Parent.jsx
var Parent = React.createClass({
render: function() {
return (<Child></Child>);
}
});
and
Child.jsx
var Child= React.createClass({
render: function() {
return (<span>CHILD</span>);
}
});
I am using babel to monitor the files for changes and output new js files when needed, and it always renders the Child component as React.createElement("Child", null) instead of React.createElement(Child, null) like I expect.
I'm new to babel and node in general and can't find a way to get this jsx transform to work as I expect. Is there something I'm missing? I feel like this pattern used to work, but I've never tried it with anything like babel before.
It took me what felt like forever to figure this out, but it turns out you can just load all the files from the HTML and then nest them later on.
HTML:
<html lang="en">
<head>
<script crossorigin src="https://unpkg.com/react#16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom#16/umd/react-dom.development.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.js"></script>
</head>
<body>
<div id="root"></div>
<div id="test"></div>
</body>
<script src="./Test3a.jsx" type="text/babel"></script>
<script src="./Test3b.jsx" type="text/babel"></script>
<script type="text/babel">
ReactDOM.render(<Ostrich />, document.getElementById("root"));
</script>
<script type="text/babel">
ReactDOM.render(<Monkey />, document.getElementById("test"));
</script>
Test3A.jsx:
window.Ostrich = function() {
return (
<div>
Ostriches
</div>
);
}
window.Monkey = function() {
return (
);
}
Test3A.jsx:
window.MoreMonkeys = function() {
return (
<div>
That's a lot of Monkeys.
</div>
);
}
This is for non-webpack "React JS", or more accurately Babel/JSX "without" ReactJS. It may not be a perfect solution, but hopefully it helps.

Google Map interfering with button event in Safari

If you press "Upload your file" in the test code below, the button text should change to "Uploading...", although in Safari it doesn't. Selecting a sufficiently large file should just give you time to observe the button. Comment out map div and it all works fine.
Here's the isolated test code, it took half a day to find that the map could be the cause, but I need to dig deeper. Interestingly, when copying the same code to JSfiddle it will not reproduce the bug, so you'll need to create your own html file.
<!DOCTYPE html>
<html>
<head>
<title>Google Map interfering with button event in Safari</title>
<meta charset="utf-8">
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var map;
function init() {
var options = {
zoom: 8,
center: new google.maps.LatLng(0, 0),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), options);
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</head>
<body>
<form action="http://localhost" method="POST" enctype="multipart/form-data">
<!--comment map to see correct button behaviour in Safari-->
<div id="map" style="width:300px;height:300px"></div>
<p><small>Very large file please:</small> <input type="file" name="big"></p>
<button onclick="this.innerHTML='Uploading...'">Upload your file</button>
</form>
</body>
</html>
There were similar questions on SO before, but no solutions.