I set up a couple of web sites several years ago that visualize survey data on clickable maps. Example:
I put a lot of effort into coding at the time and have not developed the sites further since they have continued to “do the job”. The code in the simplest form was:
<!DOCTYPE HTML>
<title>OpenLayers Simplest Example</title>
<div id="demoMap" style="height:250px"></div>
<script src="ol/ol.js" type="text/javascript"></script>
<script>
map = new OpenLayers.Map("demoMap");
map.addLayer(new OpenLayers.Layer.OSM());
map.zoomToMaxExtent();
</script>
and I have had the css- and js-files in the ol folder on the web server. After this summer all maps are down, with the errors:
Failed to load resource: net::ERR_NAME_NOT_RESOLVED polyfill.min.js:1
Uncaught SyntaxError: Unexpected token ';'
Uncaught ReferenceError: init is not defined at onload
The lines at the “unexpected token” look like this:
while ($row = mysqli_fetch_row($result_poi)) {
$rows[] = $row;
}
The error message “init is not defined” signals that the the old and basic ol code no longer works. That code looks like this:
function init() {
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
controls: ol.control.defaults({
zoom: true,
attribution: false,
rotate: true
})
});
I understand that polyfill is a compromised link and have removed it. I also understand there have been new openlayer versions since I developed my web sites, and I am certain the new versions are much better than the old one. However, the old one was very sufficient, and whilst trying to upgrade to the new version I am not even managing to get the “Simple Map” to work. I have downloaded the v10.0.0-package and unzipped the files into the ol-folder on the host, but this does not seem to work (it complains about "Uncaught TypeError: Failed to resolve module specifier "rbush". Relative references must start with either "/", "./", or "../"
). I changed all of the links in the main.js file so they pointed to the correct path, but I cannot find rbush anywhere. The quick start seems to tell me how to setup a local server with openlayers, but I’m using a host server and cannot install or configure the host.
I would really like to either get my existing code to keep working, OR adjust it to the new openlayer version. But I just don’t seem to understand the new way of using openlayers. Are my web maps lost for ever, or does someone have a solution that does not require me to relearn and recode everything? I would really appreciate some advice before messing up something that could work with minor adjustments.