forked from devlint/osmLeaflet.jQuery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
english_documentation.html
354 lines (343 loc) · 13.3 KB
/
english_documentation.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!DOCTYPE html>
<html>
<head>
<title>osmLeaflet.jQuery, a jQuery plugin for Open Street Map</title>
<meta charset="UTF-8">
<meta name="description" content="osmLeaflet.jQuery, a jQuery plugin for Open Street Map via Leaflet"/>
<link rel="stylesheet" type="text/css" href="css/kickstart.css" media="all"/>
<link rel="stylesheet" type="text/css" href="style.css" media="all"/>
<link href="http://leaflet.cloudmade.com/dist/leaflet.css" rel="stylesheet"/>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-18447506-1']);
_gaq.push(['_trackPageview']);
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
<script type="text/javascript">
/* <![CDATA[ */
(function () {
var s = document.createElement('script'), t = document.getElementsByTagName('script')[0];
s.type = 'text/javascript';
s.async = true;
s.src = 'http://api.flattr.com/js/0.6/load.js?mode=auto';
t.parentNode.insertBefore(s, t);
})();
/* ]]> */
</script>
</head>
<body>
<a id="top-of-page"></a>
<a href="https://github.com/MathRobin/osmLeaflet.jQuery"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://a248.e.akamai.net/assets.github.com/img/abad93f42020b733148435e2cd92ce15c542d320/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67"
alt="Fork me on GitHub"></a>
<div id="wrap" class="clearfix">
<div id="map1" style="height: 216px; width: 960px;"></div>
<div class="col_12">
<h4>What is osmLeaflet.jQuery?</h4>
<p>It's a jQuery plugin which is designed to help you in using the <a href="http://leaflet.cloudmade.com/" target="_blank" alt="Leaflet - a modern, lightweight JavaScript library for interactive maps by CloudMade" title="Leaflet - a modern, lightweight JavaScript library for interactive maps by CloudMade">Leaflet</a> API to display maps
based on <a href="http://www.openstreetmap.org/" target="_blank" alt="OpenStreetMap" title="OpenStreetMap">Open Street Map</a>.</p>
<h4>Skills</h4>
<div class="col_4">
<ul class="checks">
<li>Choose the zoom level at initialization</li>
<li>Then, play with the wheel mouse or zoom buttons</li>
<li>Put markers</li>
<li>Put a popup</li>
<li>Give it a rich HTML content</li>
<li>Handle maps events</li>
</ul>
</div>
<div class="col_5">
<ul class="checks">
<li>Multiples instances</li>
<li>Manage maps easily</li>
<li>BSD Licence, do what you want</li>
<li>Without any constraints</li>
<li>Simplified API in comparison to <a href="http://leaflet.cloudmade.com/" target="_blank" alt="Leaflet - a modern, lightweight JavaScript library for interactive maps by CloudMade" title="Leaflet - a modern, lightweight JavaScript library for interactive maps by CloudMade">Leaflet</a></li>
<li>Based on Leaflet and <a href="http://www.openstreetmap.org/" target="_blank" alt="OpenStreetMap" title="OpenStreetMap">Open Street Map</a></li>
</ul>
</div>
<div class="facebook-box">
<iframe src="http://www.facebook.com/plugins/likebox.php?id=124128901045591&width=220&connections=10&stream=false&header=false&height=300" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:220px; height:300px;" allowtransparency="true"></iframe>
</div>
<h4>Demonstration</h4>
<ul class="tabs">
<li class="first current"><a href="#media-example">Example</a></li>
<li class=""><a href="#media-code">Code with osmLeaflet.jQuery</a></li>
<li class=""><a href="#media-fullcode">With only the Leaflet API</a></li>
</ul>
<div id="media-example" class="tab-content clearfix" style="display: block; ">
<div id="mini_map" style="height: 140px; width: 800px;"></div>
</div>
<div id="media-code" class="tab-content clearfix" style="display: block; ">
<pre class="js prettyprint"><div id="mini_map" style="height: 140px; width: 800px;"></div>
// Just provide a JSON object and go for it! To create another instance: change the id sent to jQuery selector.
$("#mini_map").osmLeaflet({
zoom : 9,
latitude : 48.833,
longitude : 2.333,
popup : {
latitude : 48.859,
longitude : 2.333,
text : 'Hello !'
}
});
</pre>
</div>
<div id="media-fullcode" class="tab-content clearfix" style="display: block; ">
<pre class="js prettyprint"><div id="mini_map" style="height: 140px; width: 800px;"></div>
// No JSON object, more verbose but not really readable, no? To create another instance: change the map var name and the selector.
var map = new L.Map("mini_map"),
cloudmade = new L.TileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade'
}),
popup = new L.Popup();
map.setView(new L.LatLng(48.833, 2.333, 9).addLayer(cloudmade);
popup.setLatLng(new L.LatLng(48.859, 2.333));
popup.setContent('Hello !');
map.openPopup(popup);
</pre>
</div>
<h4>Follow</h4>
<a href="https://github.com/MathRobin/osmLeaflet.jQuery" alt="Github" title="Github"><span class="icon social large blue" data-icon="i" title="Github" style="display: inline-block; "></span></a>
<a href="http://www.facebook.com/PluginOsmLeafletjQuery/" alt="Facebook" title="Facebook"><span class="icon social x-large blue" data-icon="F"></span></a>
<a class="button orange small" href="http://www.mathieurobin.com/tag/osmleaflet-jquery/feed/" alt="RSS feed" title="RSS feed"><span class="icon social" data-icon="r" style="display: inline-block; "></span> RSS</a>
<a class="FlattrButton" style="display:none;" href="http://www.mathieurobin.com/osmLeaflet"></a>
<noscript><a href="http://flattr.com/thing/625244/osmLeaflet-jQuery-plugin-jQuery-pour-Open-Street-Map" target="_blank">
<img src="http://api.flattr.com/button/flattr-badge-large.png" alt="Flattr this" title="Flattr this" border="0"/></a></noscript>
<h4>Documentation</h4>
<ul>
<li><a href="#methods_init">init (options)</a></li>
<li><a href="#methods_addmarker">addMarker (options)</a></li>
<li><a href="#methods_addpopup">addPopup (options)</a></li>
<li><a href="#methods_onclick">onClick (callback)</a></li>
</ul>
<a name="methods_init"></a><h5><i>init (options)</i></h5>
<p>Create the map. Called by default if no parameters are passed.<br/><br/>Takes the following options:</p>
<table class="striped" cellspacing="0" cellpadding="0">
<thead>
<tr class="alt first last">
<th>Name</th>
<th>Type</th>
<th>Optionnal</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="first">
<th>latitude</th>
<td>Number</td>
<td>No</td>
<td>Map's latitude.</td>
</tr>
<tr class="alt">
<th>longitude</th>
<td>Number</td>
<td>No</td>
<td>Map's longitude.</td>
</tr>
<tr>
<th>markers</th>
<td>Array</td>
<td>Yes</td>
<td>Contains a list of markers with their description.</td>
</tr>
<tr class="alt">
<th>onClick</th>
<td>Function</td>
<td>Yes</td>
<td>Callback function which will be called on each click on the map. This function has the event object as parameter.</td>
</tr>
<tr>
<th>popup</th>
<td>Object</td>
<td>Yes</td>
<td>Popup's description</td>
</tr>
<tr class="alt last">
<th>zoom</th>
<td>Number</td>
<td>Yes</td>
<td>Map's zoom level. Between 1 and 18.</td>
</tr>
</tbody>
</table>
<br/>
<a name="methods_addmarker"></a><h5><i>addMarker (options)</i></h5>
<p>Allows to put one or more marker(s) on the map.<br/><br/>Takes the following options (or an array of these):</p>
<table class="striped" cellspacing="0" cellpadding="0">
<thead>
<tr class="alt first last">
<th>Name</th>
<th>Type</th>
<th>Optionnal</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="first">
<th>click</th>
<td>Object</td>
<td>No</td>
<td>Description of a popup which will be opened when clicking on the marker.</td>
</tr>
<tr class="alt">
<th>latitude</th>
<td>Number</td>
<td>Yes</td>
<td>Marker's latitude.</td>
</tr>
<tr class="last">
<th>longitude</th>
<td>Number</td>
<td>Yes</td>
<td>Marker's longitude.</td>
</tr>
</tbody>
</table>
<br/>
<a name="methods_addpopup"></a><h5><i>addPopup (options)</i></h5>
<p>Allows to put a popup on the map. Leaflet API doesn't allow to show more than one popup at a time on a map.<br/><br/>Takes the following options (or an array of these):</p>
<table class="striped" cellspacing="0" cellpadding="0">
<thead>
<tr class="alt first last">
<th>Name</th>
<th>Type</th>
<th>Optionnal</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="first">
<th>content</th>
<td>String</td>
<td>No</td>
<td>Describes, in HTML, the popup's content</td>
</tr>
<tr class="alt">
<th>latitude</th>
<td>Number</td>
<td>No</td>
<td>Popup's latitude.</td>
</tr>
<tr>
<th>longitude</th>
<td>Number</td>
<td>No</td>
<td>Popup's longitude.</td>
</tr>
<tr class="alt">
<th>autopan</th>
<td>Boolean</td>
<td>Yes</td>
<td>The popup uses the pan effect when it appears on the map. Default value: <i>true</i>.</td>
</tr>
</tbody>
</table>
<br/>
<a name="methods_onclick"></a><h5><i>onClick (callback)</i></h5>
<p>Call the callback function given as a parameter of the click event on any area of the map. Can take an <a href="http://www.jquery.com/Deferred" target="_blank" alt="jQuery - Deferred" title="jQuery - Deferred">Deferred</a> object instead of the function.<br/><br/>Takes the following parameter:</p>
<table class="striped" cellspacing="0" cellpadding="0">
<thead>
<tr class="alt first last">
<th>Name</th>
<th>Type</th>
<th>Optionnal</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr class="first">
<th>callback <a href="#tips_onclick" alt="" title="">*</a></th>
<td>Function</td>
<td>No</td>
<td>Callback function.</td>
</tr>
<tr class="alt last">
<th>callback <a href="#tips_onclick" alt="" title="">*</a></th>
<td>Deferred</td>
<td>No</td>
<td>Deferred object which will be resolved at the click event.</td>
</tr>
</tbody>
</table>
<a name="tips_onclick"></a>
<small>* Function or object, not both</small>
</div>
<div id="map2" style="height: 216px; width: 960px;"></div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script type="text/javascript" src="js/prettify.js"></script>
<script type="text/javascript" src="js/kickstart.js"></script>
<script src="http://leaflet.cloudmade.com/dist/leaflet.js"></script>
<script type="text/javascript" src="osmLeaflet.jquery.js"></script>
<script>
$(document).ready(function () {
var $map1 = $("#map1"),
$mini_map = $("#mini_map"),
$map2 = $("#map2");
// Header map
$map1.osmLeaflet({
zoom : 10,
latitude : 51.50,
longitude : -0.09
});
$map1.osmLeaflet('addMarker', {
latitude : 51.50,
longitude : -0.09
});
$map1.osmLeaflet('addPopup', {
latitude : 51.51,
longitude : -0.13,
content : '<b>Hey !</b> Welcome on <a href="http://www.mathieurobin.com/osmLeaflet/" target="_blank">osmLeaflet.jQuery</a> website'
});
$map1.osmLeaflet('addMarker', [
{
latitude : 49.50,
longitude : -0.09
},
{
latitude : 49.40,
longitude : -0.09
},
{
latitude : 49.30,
longitude : -0.09
}
]);
// Demo map
$mini_map.osmLeaflet({
zoom : 9,
latitude : 48.833,
longitude : 2.333
});
$mini_map.osmLeaflet('addPopup', {
latitude : 48.859,
longitude : 2.333,
content : 'Hello !'
});
// Footer map
$map2.osmLeaflet({
zoom : 2,
latitude : 21.50,
longitude : 22.5
});
$map2.osmLeaflet('addPopup', {
latitude : 21.51,
longitude : 22.54,
content : 'Have a nice day !'
});
});
</script>
</body>
</html>