Move javascript from html to js file

This commit is contained in:
Alexey Zakharenkov 2019-06-19 12:00:56 +03:00
parent 47f978cd42
commit 9e23028638
2 changed files with 19 additions and 20 deletions

View file

@ -1,3 +1,22 @@
const OSM_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const OSM_ATTRIB = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
var osm_layer = L.tileLayer(OSM_URL, {
maxZoom: 18,
attribution: OSM_ATTRIB,
opacity: 0.5
});
var initialLocation = [55.7510888, 37.7642849];
var map = L.map('map').setView(initialLocation, 15).addLayer(osm_layer);
L.marker(initialLocation)
.addTo(map)
.bindPopup('Choose a city from the list at the top-right corner!')
.openPopup();
function slugify(name) {
name = name.toLowerCase();
name = name.replace(/ /g, '_');

View file

@ -22,30 +22,10 @@
}
</style>
<script>
OSM_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
</script>
</head>
<body>
<div id="map"></div>
<script>
var osmAttrib = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(OSM_URL, {
maxZoom: 18,
attribution: osmAttrib,
opacity: 0.5
});
var initialLocation = [55.7510888, 37.7642849];
var map = L.map('map').setView(initialLocation, 15).addLayer(osm);
L.marker(initialLocation)
.addTo(map)
.bindPopup('Choose a city from the list at the top-right corner!')
.openPopup();
</script>
<script src="js/lib/xhr.js"></script>
<script src="js/metro.js"></script>
</body>