New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve step-by-step tutorials #7254
Comments
The Leaflet Quick Start Guide, the most basic tutorial, doesn't even build the example step by step with code the users can post straight into the code development environment (eg https://www.tutorialspoint.com/leafletjs/leafletjs_getting_started.htm). In the Leaflet Quick Start Guide not all necessary code is used/explained in the exampleCode used/explained in the demo example is highlighted below with <!DOCTYPE html>
<html>
<head>
<title>Quick Start - Leaflet</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" type="image/x-icon" href="docs/images/favicon.ico" />
| <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin=""/>
| <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
</head>
<body>
? <div id="mapid" style="width: 600px; height: 400px;"></div>
<script>
| var mymap = L.map('mapid').setView([51.505, -0.09], 13);
| L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
| maxZoom: 18,
| attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
| '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
| 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
| id: 'mapbox/streets-v11',
| tileSize: 512,
| zoomOffset: -1
| }).addTo(mymap);
? L.marker([51.5, -0.09]).addTo(mymap)
.bindPopup("<b>Hello world!</b><br />I am a popup.").openPopup();
? L.circle([51.508, -0.11], 500, {
| color: 'red',
| fillColor: '#f03',
| fillOpacity: 0.5
? }).addTo(mymap).bindPopup("I am a circle.");
? L.polygon([
| [51.509, -0.08],
| [51.503, -0.06],
| [51.51, -0.047]
? ]).addTo(mymap).bindPopup("I am a polygon.");
| var popup = L.popup();
|
| function onMapClick(e) {
| popup
| .setLatLng(e.latlng)
| .setContent("You clicked the map at " + e.latlng.toString())
| .openOn(mymap);
| }
|
| mymap.on('click', onMapClick);
</script>
</body>
</html> It should explain the html, js and css files work together and start with:
|
This comment specifically refers to Using GeoJSON with Leaflet but apply more generally.
A tutorial should work towards a solution step by step allowing opportunities for people to try what they are learning. The tutorial is frustrating, the examples aren't used in the demo example at the end and the files where the content occurs aren't referenced.
This tutorial could easily follow the Leaflet Quick Start Guide tutorial by adding geojson data step by step. This would ensure the preparation of the map is fully explained even though the basics are out of scope for this topic.
All of tutorial example code should come directly from the demo example but not all code in the demo example needs to be presented in more advanced tutorials.
Undoubtedly the API has changed since this tutorial was first written. It is time to review the tutorial to realign the tutorial examples and the demo example so the GeoJSON API is demonstrated. The coding style and constructs are very different between the tutorial and the demo example. For example, there are two tutorial style types and neither is a good match for the demo example.
I have changed the tutorial section below to use the demo example but it really demonstrates the demo example (including data) would be better to be reworked to demonstrate the tutorial examples:
Example improvements to the Using GeoJSON with Leaflet tutorial
The text was updated successfully, but these errors were encountered: