Skip to content
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

Add a editor tutorial with CSS and HTML panes. #783

Merged
merged 2 commits into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tutorials/editor/tutorial.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"title": "Editor",
"hideNavbar": true,
"level": 10,
"order": 0,
"tutorialJs": ["editor.js"],
"about": {
"text": "Edit and save work in URL."
Expand Down
7 changes: 7 additions & 0 deletions tutorials/editor3/editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* global start_tutorial */

$(function () {
/* start_tutorial has to be called explicitly when we are ready since we need
* to ask it to always keep url changes. */
start_tutorial(undefined, true);
});
69 changes: 69 additions & 0 deletions tutorials/editor3/index.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
extends ../common/index.pug

block mainTutorial
:markdown-it
# Editor with HTML and CSS
Any changes made will be stored in the URL whenever the code is run. This can be sent as a link, bookmarked, or otherwise shared.

You can interact with the code through the javascript console by accessing the top-level variables in the `tutorial` global parameter.

:markdown-it
**HTML**
+codeblock('html', 1).
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../../built/geo.ext.min.js"></script>
<script type="text/javascript" src="../../built/geo.min.js"></script>
<!-- Use a specific version of GeoJS by requesting it from a CDN.
For instance, remove the local references, above, and
uncomment the following:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/geojs/0.15.1/geo.ext.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/geojs/0.15.1/geo.min.js"></script>
-->
</head>
<body>
<div id="map"></div>
<div id="info"></div>
</body>
</html>

:markdown-it
**CSS**
+codeblock('css', 2).
html,body,#map{
width: 100%;
height: 100%;
padding: 0;
margin: 0;
overflow: hidden;
}
#info {
position: absolute;
top: 0;
right: 0;
background: rgba(255,255,255,0.75);
padding: 2px;
}

:markdown-it
**Javascript**
+codeblock('javascript', 3, undefined, true).
var map = geo.map({
node: "#map",
center: {x: 0.2, y: 49.5},
zoom: 11
});
var layer = map.createLayer('osm');
$('#info').text('GeoJS version: ' + geo.version);
map.geoOn(geo.event.mousemove, function (evt) {
$('#info').text('x: ' + evt.geo.x.toFixed(6) + ', y: ' + evt.geo.y.toFixed(6));
})
+codeblock_test('map has one osm layer from openstreetmap', [
'map.layers().length === 1',
'map.layers()[0] instanceof geo.osmLayer',
'layer.url().match(/openstreetmap/)'
])
+codeblock_test('map has a non-empty info div', [
'$("#info").text()'
])
Binary file added tutorials/editor3/thumb.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tutorials/editor3/tutorial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"title": "Editor with HTML and CSS",
"hideNavbar": true,
"level": 10,
"order": 1,
"tutorialJs": ["editor.js"],
"about": {
"text": "Edit and save work in URL. Edit the HTML to try different versions of GeoJS."
}
}