Skip to content

Commit 65ae131

Browse files
authored
Merge pull request #2 from hreikin/documentation
Documentation Update
2 parents 896c528 + 7e9e200 commit 65ae131

File tree

4 files changed

+120
-78
lines changed

4 files changed

+120
-78
lines changed

README.md

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,39 @@ A detailed guide is available to view [here](https://www.hreikin.co.uk/2018/06/0
3131

3232
Create the map and set a flat projection, as we are projecting an image. Then create the Zoomify tile layer.
3333
```js
34+
//Creates the map, tells it to display in the element with id of 'mapid' and sets a flat projection, as we are projecting an image.
3435
var map = L.map('mapid', {
35-
crs: L.CRS.Simple,
36+
crs: L.CRS.Simple, //Set a flat CRS (Coordinate Reference System) projection as we are projecting an image.
3637
});
3738

39+
//Change the URL to reflect where you are hosting your map tiles. Width and Height of original image MUST be defined.
3840
var layer = L.tileLayer.zoomify('./interactive-campaign-map-start/{g}/{z}-{x}-{y}.jpg', {
39-
width: 8318,
40-
height: 3640,
41+
width: 8318, // MUST be defined.
42+
height: 3640, // MUST be defined.
4143
}).addTo(map);
4244

45+
//Setting the view to our layer bounds, set by our Zoomify plugin.
4346
map.fitBounds(layer.getBounds());
4447
```
4548

4649
Declare which icons to use for the Player and Battle markers.
4750
```js
51+
// Create the icon used for the player markers. May be changed to any image you wish.
4852
var playerIcon = L.icon({
49-
iconUrl: 'images/players.png',
50-
iconSize: [38, 38],
53+
iconUrl: 'images/players.png', // Location of file to be used as icon.
54+
iconSize: [38, 38], // Size of icon on map.
5155
});
5256

57+
// Create the icon used for the battle markers. May be changed to any image you wish.
5358
var battleIcon = L.icon({
54-
iconUrl: 'images/battles.png',
55-
iconSize: [50, 50],
59+
iconUrl: 'images/battles.png', // Location of file to be used as icon.
60+
iconSize: [50, 50], // Size of icon on map.
5661
});
5762
```
5863

5964
Declare the popup content for any Player or Battle popups.
6065
```js
66+
// Create the player popup content. You can change these to include player bios, army lists, etc for each individual player. Accepts HTML content such as images and links.
6167
var redPlayerPopup = 'Player information can go here, it could include details such as army/gang/faction and a link to their list or roster. The icon can be set to any image, it could be either a profile picture of the player or a recognisable army/gang/faction mark.';
6268
var turquoisePlayerPopup = 'Player information can go here, it could include details such as army/gang/faction and a link to their list or roster. The icon can be set to any image, it could be either a profile picture of the player or a recognisable army/gang/faction mark.';
6369
var lightgreenPlayerPopup = 'Player information can go here, it could include details such as army/gang/faction and a link to their list or roster. The icon can be set to any image, it could be either a profile picture of the player or a recognisable army/gang/faction mark.';
@@ -69,6 +75,7 @@ var greenPlayerPopup = 'Player information can go here, it could include details
6975
var darkBluePlayerPopup = 'Player information can go here, it could include details such as army/gang/faction and a link to their list or roster. The icon can be set to any image, it could be either a profile picture of the player or a recognisable army/gang/faction mark.';
7076
var lightBluePlayerPopup = 'Player information can go here, it could include details such as army/gang/faction and a link to their list or roster. The icon can be set to any image, it could be either a profile picture of the player or a recognisable army/gang/faction mark.';
7177

78+
// Stage 01 battles popup content. You can change these to include results, etc for each battle that occurred this stage. Accepts HTML content such as images and links.
7279
var redPlayerStage01Battle01Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
7380
var redPlayerStage01Battle02Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
7481
var lightGreenPlayerStage01Battle01Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
@@ -84,6 +91,7 @@ var lightBluePlayerStage01Battle01Popup = 'Battle information and results can go
8491
var turquoisePlayerStage01Battle01Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
8592
var turquoisePlayerStage01Battle02Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
8693

94+
// Stage 02 battles popup content. You can change these to include results, etc for each battle that occurred this stage. Accepts HTML content such as images and links.
8795
var redPlayerStage02Battle01Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
8896
var lightGreenPlayerStage02Battle01Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
8997
var yellowPlayerStage02Battle01Popup = 'Battle information and results can go here with a link to any results/league tables. The icon can be set to any image.';
@@ -99,6 +107,7 @@ var turquoisePlayerStage02Battle01Popup = 'Battle information and results can go
99107

100108
Create the Player markers and set the latitude and longitude values and then pass any options for custom icon and custom popup values. Then create a group of Player markers to be added to the layer control and add the player markers group to the map.
101109
```js
110+
// Creates the player markers, sets the latitude and longitude. Passes options for custom icon and custom popup values.
102111
var redPlayer = L.marker([-10.0, 10.0], {icon: playerIcon}).bindPopup(redPlayerPopup);
103112
var lightGreenPlayer = L.marker([-21.0, 33.0], {icon: playerIcon}).bindPopup(lightgreenPlayerPopup);
104113
var yellowPlayer = L.marker([-25.0, 61.0], {icon: playerIcon}).bindPopup(yellowPlayerPopup);
@@ -110,11 +119,13 @@ var darkBluePlayer = L.marker([-44.0, 73.0], {icon: playerIcon}).bindPopup(darkB
110119
var lightBluePlayer = L.marker([-48.0, 49.0], {icon: playerIcon}).bindPopup(lightBluePlayerPopup);
111120
var turquoisePlayer = L.marker([-45.0, 16.0], {icon: playerIcon}).bindPopup(turquoisePlayerPopup);
112121

122+
// Creates a group of player markers to be added to layer control later. Adds player markers to map.
113123
var players = L.layerGroup([redPlayer, lightGreenPlayer, yellowPlayer, bluePlayer, orangePlayer, purplePlayer, greenPlayer, darkBluePlayer, lightBluePlayer, turquoisePlayer]).addTo(map);
114124
```
115125

116126
Create the Battle markers for each stage and set the latitude and longitude values and then pass any options for custom icon and custom popup values. Then create a group of Battle markers for each stage to be added to the layer control.
117127
```js
128+
// Creates the stage 01 battle markers, sets the latitude and longitude. Passes options for custom icon and custom popup values.
118129
var redPlayerStage01Battle01 = L.marker([-3.5, 5.0], {icon: battleIcon}).bindPopup(redPlayerStage01Battle01Popup);
119130
var redPlayerStage01Battle02 = L.marker([-4.0, 15.0], {icon: battleIcon}).bindPopup(redPlayerStage01Battle02Popup);
120131
var lightGreenPlayerStage01Battle01 = L.marker([-13.0, 30.0], {icon: battleIcon}).bindPopup(lightGreenPlayerStage01Battle01Popup);
@@ -130,8 +141,10 @@ var lightBluePlayerStage01Battle01 = L.marker([-54.0, 50.0], {icon: battleIcon})
130141
var turquoisePlayerStage01Battle01 = L.marker([-43.0, 27.0], {icon: battleIcon}).bindPopup(turquoisePlayerStage01Battle01Popup);
131142
var turquoisePlayerStage01Battle02 = L.marker([-44.0, 37.0], {icon: battleIcon}).bindPopup(turquoisePlayerStage01Battle02Popup);
132143

144+
// Creates a group of stage 01 battle markers to be added to layer control later.
133145
var battlesStage01 = L.layerGroup([redPlayerStage01Battle01, redPlayerStage01Battle02, lightGreenPlayerStage01Battle01, yellowPlayerStage01Battle01, yellowPlayerStage01Battle02, bluePlayerStage01Battle01, orangePlayerStage01Battle01, purplePlayerStage01Battle01, purplePlayerStage01Battle02, greenPlayerStage01Battle01, darkBluePlayerStage01Battle01, lightBluePlayerStage01Battle01, turquoisePlayerStage01Battle01, turquoisePlayerStage01Battle02]);
134146

147+
// Creates the stage 02 battle markers, sets the latitude and longitude. Passes options for custom icon and custom popup values.
135148
var redPlayerStage02Battle01 = L.marker([-4.0, 28.0], {icon: battleIcon}).bindPopup(redPlayerStage02Battle01Popup);
136149
var lightGreenPlayerStage02Battle01 = L.marker([-30.0, 36.0], {icon: battleIcon}).bindPopup(lightGreenPlayerStage02Battle01Popup);
137150
var yellowPlayerStage02Battle01 = L.marker([-14.0, 58.0], {icon: battleIcon}).bindPopup(yellowPlayerStage02Battle01Popup);
@@ -144,50 +157,55 @@ var lightBluePlayerStage02Battle01 = L.marker([-53.0, 63.0], {icon: battleIcon})
144157
var lightBluePlayerStage02Battle02 = L.marker([-40.0, 37.0], {icon: battleIcon}).bindPopup(lightBluePlayerStage02Battle02Popup);
145158
var turquoisePlayerStage02Battle01 = L.marker([-41.0, 48.0], {icon: battleIcon}).bindPopup(turquoisePlayerStage02Battle01Popup);
146159

160+
// Creates a group of stage 02 battle markers to be added to layer control later.
147161
var battlesStage02 = L.layerGroup([redPlayerStage02Battle01, lightGreenPlayerStage02Battle01, yellowPlayerStage02Battle01, bluePlayerStage02Battle01, orangePlayerStage02Battle01, purplePlayerStage02Battle01, greenPlayerStage02Battle01, darkBluePlayerStage02Battle01, lightBluePlayerStage02Battle01, lightBluePlayerStage02Battle02, turquoisePlayerStage02Battle01]);
148162
```
149163

150164
Create the switchable map layers and add them to the map. Width and Height of original image MUST be defined.
151165
```js
166+
//Creates the switchable map layers. Change the URL to reflect where you are hosting your map tiles. Width and Height of original image MUST be defined.
152167
var start = L.tileLayer.zoomify('./interactive-campaign-map-start/{g}/{z}-{x}-{y}.jpg', {
153-
width: 8318,
154-
height: 3640,
168+
width: 8318, // MUST be defined.
169+
height: 3640, // MUST be defined.
155170
tolerance: 0.9,
156-
layers: [stage01, stage02, players, battlesStage01, battlesStage02],
157-
attribution: 'Map by <a href="https://hreikin.co.uk" target="_blank" alt="hreikin">@hreikin</a>'
171+
layers: [stage01, stage02, players, battlesStage01, battlesStage02], //Layers to include in layers control, initial map should NOT be included as it will be added automatically.
172+
attribution: 'Map by <a href="https://hreikin.co.uk" target="_blank" alt="hreikin">@hreikin</a>' // Attribution which appears in the bottom left corner, change this value to whatever you like.
158173
}).addTo(map),
159174

160175
stage01 = L.tileLayer.zoomify('./interactive-campaign-map-stage-01/{g}/{z}-{x}-{y}.jpg', {
161-
width: 8318,
162-
height: 3640,
176+
width: 8318, // MUST be defined.
177+
height: 3640, // MUST be defined.
163178
tolerance: 0.9,
164-
layers: [stage01, stage02, players, battlesStage01, battlesStage02],
165-
attribution: 'Map by <a href="https://hreikin.co.uk" target="_blank" alt="hreikin">@hreikin</a>'
179+
layers: [stage01, stage02, players, battlesStage01, battlesStage02], //Layers to include in layers control, initial map should NOT be included as it will be added automatically.
180+
attribution: 'Map by <a href="https://hreikin.co.uk" target="_blank" alt="hreikin">@hreikin</a>' // Attribution which appears in the bottom left corner, change this value to whatever you like.
166181
}),
167182

168183
stage02 = L.tileLayer.zoomify('./interactive-campaign-map-stage-02/{g}/{z}-{x}-{y}.jpg', {
169-
width: 8318,
170-
height: 3640,
184+
width: 8318, // MUST be defined.
185+
height: 3640, // MUST be defined.
171186
tolerance: 0.9,
172-
layers: [stage01, stage02, players, battlesStage01, battlesStage02],
173-
attribution: 'Map by <a href="https://hreikin.co.uk" target="_blank" alt="hreikin">@hreikin</a>'
187+
layers: [stage01, stage02, players, battlesStage01, battlesStage02], //Layers to include in layers control, initial map should NOT be included as it will be added automatically.
188+
attribution: 'Map by <a href="https://hreikin.co.uk" target="_blank" alt="hreikin">@hreikin</a>' // Attribution which appears in the bottom left corner, change this value to whatever you like.
174189
});
175190
```
176191

177192
Create the baseMaps and overlayMaps layers and passes which map layers to include in the layers control. Then create the layers control and add it to the map.
178193
```js
194+
// Creates baseMaps layer and passes which maps to include in the layers control.
179195
var baseMaps = {
180-
"Campaign Start": start,
181-
"Campaign Stage 01": stage01,
182-
"Campaign Stage 02": stage02
196+
"Campaign Start": start, // The value within quotation marks is the name of the switchable control as it appears on the map. The second value is the layer name.
197+
"Campaign Stage 01": stage01, // The value within quotation marks is the name of the switchable control as it appears on the map. The second value is the layer name.
198+
"Campaign Stage 02": stage02 // The value within quotation marks is the name of the switchable control as it appears on the map. The second value is the layer name.
183199
};
184200

201+
// Creates overlayMaps layer and passes which marker groups to include in the layers control.
185202
var overlayMaps = {
186-
"Players": players,
187-
"Stage 1 Battles": battlesStage01,
188-
"Stage 2 Battles": battlesStage02
203+
"Players": players, // The value within quotation marks is the name of the switchable control as it appears on the map. The second value is the group name.
204+
"Stage 1 Battles": battlesStage01, // The value within quotation marks is the name of the switchable control as it appears on the map. The second value is the group name.
205+
"Stage 2 Battles": battlesStage02 // The value within quotation marks is the name of the switchable control as it appears on the map. The second value is the group name.
189206
};
190207

208+
// Creates a switchable layers control from baseMaps and overlayMaps and adds them to map.
191209
L.control.layers(baseMaps, overlayMaps).addTo(map);
192210
```
193211

0 commit comments

Comments
 (0)