aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2015-03-14 14:43:00 +0000
committerChristopher Baines <mail@cbaines.net>2015-03-14 14:43:00 +0000
commit5324d2bfc2de44e59bb7f5641af338a034f53fd8 (patch)
tree9d9fe61843e3e245c82c643ea159bc1049938b1d
parent72bc678348760a14e0e6654359e22ee5083676ef (diff)
downloadleaflet-indoor-5324d2bfc2de44e59bb7f5641af338a034f53fd8.tar
leaflet-indoor-5324d2bfc2de44e59bb7f5641af338a034f53fd8.tar.gz
Fix markdown code blocks
This works properly with the md2html used by cgit.
-rw-r--r--README.md130
1 files changed, 59 insertions, 71 deletions
diff --git a/README.md b/README.md
index 493a140..fbddf7e 100644
--- a/README.md
+++ b/README.md
@@ -21,25 +21,23 @@ See the included example for usage.
Create a L.Indoor, then add the data to it.
-`
-// where data is a GeoJSON feature collection
-var indoorLayer = new L.Indoor(data);
+ // where data is a GeoJSON feature collection
+ var indoorLayer = new L.Indoor(data);
-// set the initial level to show
-indoorLayer.setLevel("0");
+ // set the initial level to show
+ indoorLayer.setLevel("0");
-indoorLayer.addTo(map);
+ indoorLayer.addTo(map);
-var levelControl = new L.Control.Level({
- level: "0",
- levels: indoorLayer.getLevels()
-});
+ var levelControl = new L.Control.Level({
+ level: "0",
+ levels: indoorLayer.getLevels()
+ });
-// Connect the level control to the indoor layer
-levelControl.addEventListener("levelchange", indoorLayer.setLevel, indoorLayer);
+ // Connect the level control to the indoor layer
+ levelControl.addEventListener("levelchange", indoorLayer.setLevel, indoorLayer);
-levelControl.addTo(map);
-`
+ levelControl.addTo(map);
### Usage Instructions
@@ -47,86 +45,76 @@ The data should be a GeoJSON feature collection (or an array of GeoJSON
features). With the standard configuration, each feature must have a property
attribute "level", which can be a integer, string or array of either (or both).
-`
-{
- type: "FeatureCollection",
- features: [
- {
- type: "Feature",
- geometry: ...,
- properties: {
- ...
- level: 1
- ....
+ {
+ type: "FeatureCollection",
+ features: [
+ {
+ type: "Feature",
+ geometry: ...,
+ properties: {
+ ...
+ level: 1
+ ....
+ }
+ },
+ {
+ type: "Feature",
+ geometry: ...,
+ properties: {
+ ...
+ level: [2, 3]
+ ....
+ }
}
- },
- {
- type: "Feature",
- geometry: ...,
- properties: {
- ...
- level: [2, 3]
- ....
- }
- }
- ]
-}
-```
+ ]
+ }
If the data is not in this format, you can pass in a replacement getLevel
function, that will be used to get the level for each Feature.
-`
-var indoorLayer = new L.Indoor(data, {
- getLevel: function(feature) {
- return feature.properties.otherLevel;
- }
- onEachFeature
+ var indoorLayer = new L.Indoor(data, {
+ getLevel: function(feature) {
+ return feature.properties.otherLevel;
+ }
+ onEachFeature
- markerForFeature
-});
-`
+ markerForFeature
+ });
L.Control.Level is the user interface component that allows for the easy
switching of levels. It takes in some levels (which you can get from the indoor
layer by using getLevels()), and displays a list.
-`
-var levelControl = new L.Control.Level({
- level: "0",
- levels: indoorLayer.getLevels()
-});
-`
+ var levelControl = new L.Control.Level({
+ level: "0",
+ levels: indoorLayer.getLevels()
+ });
When using the L.Control.Indoor, if the levels are not integers, by default,
the levels will be converted to integers for the ordering in the control. If
the levels given to the control are not integers, then the parseLevel option
can be used to replace the default function that uses parseInt(level, 10).
-`
-var levelControl = new L.Control.Level({
- level: "1A",
- levels: indoorLayer.getLevels()
- parseLevel: function(level) {
- var levels = {
- "1A": 1,
- "1B": 2,
- "1C": 3,
- "2": 4
- };
- return levels[level];
- }
-});
-`
+ var levelControl = new L.Control.Level({
+ level: "1A",
+ levels: indoorLayer.getLevels()
+ parseLevel: function(level) {
+ var levels = {
+ "1A": 1,
+ "1B": 2,
+ "1C": 3,
+ "2": 4
+ };
+ return levels[level];
+ }
+ });
You can then bind the "levelchange" event, to change the level displayed by the
layer. Note that the levels that the control has must match that used by the
layer, if the levels in the control have been set via getLevels), this should
be the case.
-`
-levelControl.addEventListener("levelchange", indoorLayer.setLevel, indoorLayer);
-`
+ levelControl.addEventListener("levelchange", indoorLayer.setLevel, indoorLayer);
## Events