Move javascript from html to js file
This commit is contained in:
parent
47f978cd42
commit
9e23028638
2 changed files with 19 additions and 20 deletions
|
@ -1,3 +1,22 @@
|
|||
const OSM_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
const OSM_ATTRIB = '© <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, '_');
|
||||
|
|
|
@ -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 = '© <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>
|
||||
|
|
Loading…
Add table
Reference in a new issue