In the OpenLayers examples online such as this one:
https://openlayers.org/en/latest/examples/accessible.html
I see them import the following script:
<script src="https://openlayers.org/en/v4.6.4/build/ol.js"</script>
However, in many places online such as this SE question:
OpenLayers take user input of XY and create a point
I see them use this script for open layer:
<script src="http://openlayers.org/api/OpenLayers.js"></script>
What are the differences? Is it just a version difference? Why is one called ol.js and the other OpenLayers.js?
Best Answer
It is just a version difference as you suspected.
http://openlayers.org/api/OpenLayers.js
is for OpenLayers 2.x.There was a rewrite at OpenLayer 3, and the .js file gets renamed to the shorter
ol.js
. (And so are the variables etc.)There are many differences between openlayers 2 and 3+. Among them, some of the openlayers 2 functions are no longer provided in OpenLayers 3+ (due to a change of philosophy). See e.g. Missing LayerSwitcher in OpenLayers3? and other GIS.SE questions.