-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzp_openstreetmap.php
639 lines (600 loc) · 22.8 KB
/
zp_openstreetmap.php
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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
<?php
/**
* Plugin for showing OpenStreetMap maps using LeafletJS (http://leafletjs.com) for images or images from albums with embeded geodata or maps with custom geodata.
* Also includes the marker cluster plugin https://github.com/Leaflet/Leaflet.markercluster by Dave Leaver.
*
* @author Malte Müller (acrylian)
* @package plugins
* @subpackage media
*/
$plugin_is_filter = 5 | THEME_PLUGIN;
$plugin_description = gettext("Plugin for showing OpenStreetMap maps using LeafletJS for images or images from albums with embeded geodata.");
$plugin_author = "Malte Müller (acrylian)";
$plugin_version = '1.0';
$option_interface = 'zpOpenStreetMapOptions';
zp_register_filter('theme_head', 'zpOpenStreetMap::scripts');
class zpOpenStreetMapOptions {
function __construct() {
setOptionDefault('osmap_width', '100%'); //responsive by default!
setOptionDefault('osmap_height', '300px');
setOptionDefault('osmap_zoom', 4);
setOptionDefault('osmap_minzoom', 2);
setOptionDefault('osmap_maxzoom', 18);
setOptionDefault('osmap_controlpos', 'topleft');
setOptionDefault('osmap_maptiles', 'OpenStreetMap_Mapnik');
setOptionDefault('osmap_clusterradius', 40);
setOptionDefault('osmap_markerpopup', 1);
setOptionDefault('osmap_markerpopup_thumb', 1);
setOptionDefault('osmap_showscale', 1);
}
function getOptionsSupported() {
return array(
gettext('Map dimensions—width') => array(
'key' => 'osmap_width',
'type' => OPTION_TYPE_TEXTBOX,
'desc' => gettext("Width of them map including the unit name e.g 100% (default for responsive map), 100x or 100em.")),
gettext('Map dimensions—height') => array(
'key' => 'osmap_height',
'type' => OPTION_TYPE_TEXTBOX,
'desc' => gettext("Height of them map including the unit name e.g 100% (default for responsive map), 100x or 100em.")),
gettext('Map zoom') => array('key' => 'osmap_zoom', 'type' => OPTION_TYPE_TEXTBOX,
'desc' => gettext("Default zoom level.")),
gettext('Map minimum zoom') => array('key' => 'osmap_minzoom', 'type' => OPTION_TYPE_TEXTBOX,
'desc' => gettext("Default minimum zoom level possible.")),
gettext('Map maximum zoom') => array('key' => 'osmap_maxzoom', 'type' => OPTION_TYPE_TEXTBOX,
'desc' => gettext("Default maximum zoom level possible.")),
gettext('Controls position') => array(
'key' => 'osmap_maptiles',
'type' => OPTION_TYPE_SELECTOR,
'order' => 4,
'selections' => array(
gettext('Top left') => 'topleft',
gettext('Top right') => 'topright',
gettext('Bottom left') => 'bottomleft',
gettext('Bottom right') => 'bottomright'
),
'desc' => gettext('Position of the map controls')),
gettext('Map tiles') => array(
'key' => 'osmap_maptiles',
'type' => OPTION_TYPE_SELECTOR,
'order' => 4,
'selections' => array(
'OpenStreetMap_Mapnik' => 'OpenStreetMap_Mapnik',
'OpenStreetMap_BlackAndWhite' => 'OpenStreetMap_BlackAndWhite',
'OpenStreetMap_DE' => 'OpenStreetMap_DE',
'OpenStreetMap_HOT' => 'OpenStreetMap_HOT',
'Thunderforest_OpenCycleMap' => 'Thunderforest_OpenCycleMap',
'Thunderforest_Transport' => 'Thunderforest_Transport',
'Thunderforest_Landscape' => 'Thunderforest_Landscape',
'Thunderforest_Outdoors' => 'Thunderforest_Outdoors',
'OpenMapSurfer_Roads' => 'OpenMapSurfer_Roads',
'MapQuestOpen_OSM' => 'MapQuestOpen_OSM',
'MapQuestOpen_Aerial' => 'MapQuestOpen_Aerial',
'Stamen_Toner' => 'Stamen_Toner',
'Stamen_TonerBackground' => 'Stamen_TonerBackground',
'Stamen_TonerLite' => 'Stamen_TonerLite',
'Stamen_Watercolor' => 'Stamen_Watercolor'
),
'desc' => gettext('The map tile provider to use. Only free providers are included. If you wish to use any commercial provider you have to use the class base of this plugin programmatically.')),
gettext('Cluster radius') => array(
'key' => 'osmap_clusterradius',
'type' => OPTION_TYPE_TEXTBOX,
'desc' => gettext("The radious when marker clusters should be used.")),
gettext('Marker popups') => array(
'key' => 'osmap_markerpopup',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable this if you wish info popups on the map markers. Only for album context or custom geodata.")),
gettext('Marker popups with thumbs') => array(
'key' => 'osmap_markerpopup_thumb',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable if you want to show thumb of images in the marker popups. Only for album context.")),
gettext('Show scale') => array(
'key' => 'osmap_showscale',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable if you want to show scale overlay (kilometers and miles).")),
gettext('Show cursor position') => array(
'key' => 'osmap_showcursorpos',
'type' => OPTION_TYPE_CHECKBOX,
'desc' => gettext("Enable if you want to show the coordinates if moving the cursor over the map."))
);
}
}
/**
* The base class
*/
class zpOpenStreetMap {
/**
* Contains the array of the image or images from albums geodata
* @var array
*/
var $geodata = NULL;
/**
* Contains a string presenting a Javascript array of geodata for leafletjs
* @var array
*/
var $geodatajs = NULL;
/**
* geodata array('min' => array(lat,lng), 'max => array(lat,lng))
* Default created from an image or the images of an album.
* @var array
*/
var $fitbounds = NULL;
/**
* geodata array(lat,lng)
* Default created from an image or the images of an album.
* @var array
*/
var $center = NULL;
/**
* Optional lass name to attach to the map html
* @var string
*/
var $class = '';
/**
* "single" (one marker), "cluster" (several markers always clustered)
* Default created by the $geodata property: "single "if array with one entry, "cluster" if more entries
* @var string
*/
var $mode = NULL;
/**
* geodata array(lat,lng)
* Default created from the image marker or from the markers of the images of an album if in context
* @var array
*/
var $mapcenter = NULL;
/**
* Unique number if using more than one map on a page
* @var int
*/
var $mapnumber = '';
/**
* Default 100% for responsive map. Values like "100%", "100px" or "100em"
* Default taken from plugin options
* @var string
*/
var $width = '100%';
/**
* Values like "100px" or "100em"
* Default taken from plugin options
* @var string
*/
var $height = NULL;
/**
* Default zoom state
* Default taken from plugin options
* @var int
*/
var $zoom = NULL;
var $minzoom = NULL;
var $maxzoom = NULL;
/**
* The tile provider to use. Select from the $tileprovider property like $this->maptiles = $this->tileprover['<desired provier']
* Default taken from plugin options
* Must be like array('<map provider url>','<attribution as requested>')
* Default taken from plugin options
* @var array
*/
var $maptiles = NULL;
/**
* Radius when clusters should be created on more than one marker
* Default taken from plugin options
* @var int
*/
var $clusterradius = NULL;
/**
* If used on albums or several custom markers if you wish popups on the markers
* If using custom markers you need to provide the content for the popups withn the $geodata property
* Default taken from plugin options
* @var bool
*/
var $markerpopup = false;
/**
* Only if on an album page and if $imagepopups are enabled.
* If the imagepopus should contain thumbs of the images
* Default taken from plugin options
* @var bool
*/
var $markerpopup_thumb = false;
var $showmarkers = true;
/**
* Position of the map controls: "topleft", "topright", "bottomleft", "bottomright"
* Default taken from plugin options
* @var string
*/
var $controlpos = NULL;
var $showscale = NULL;
var $showcursorpos = NULL;
/**
* The current image or album object if not passing custom geodata
* @var object
*/
var $obj = NULL;
/**
* Predefined array of all free map tile providers for Open Street Map
* @var type
*/
var $tileproviders = array(
'OpenStreetMap_Mapnik' => 'OpenStreetMap_Mapnik',
'OpenStreetMap_BlackAndWhite' => 'OpenStreetMap_BlackAndWhite',
'OpenStreetMap_DE' => 'OpenStreetMap_DE',
'OpenStreetMap_HOT' => 'OpenStreetMap_HOT',
'Thunderforest_OpenCycleMap' => 'Thunderforest_OpenCycleMap',
'Thunderforest_Transport' => 'Thunderforest_Transport',
'Thunderforest_Landscape' => 'Thunderforest_Landscape',
'Thunderforest_Outdoors' => 'Thunderforest_Outdoors',
'OpenMapSurfer_Roads' => 'OpenMapSurfer_Roads',
'MapQuestOpen_OSM' => 'MapQuestOpen_OSM',
'MapQuestOpen_Aerial' => 'MapQuestOpen_Aerial',
'Stamen_Toner' => 'Stamen_Toner',
'Stamen_TonerBackground' => 'Stamen_TonerBackground',
'Stamen_TonerLite' => 'Stamen_TonerLite',
'Stamen_Watercolor' => 'Stamen_Watercolor'
);
/**
* If no $geodata array is passed the function gets geodata from the current image or the images of the current album
* if in appropiate context.
*
* Alternatively you can pass an image or album object directly. This ignores the $geodata parameter then.
*
* The $geodata array requires this structure:
* Single marker:
*
* array(
* array(
* 'lat' => <latitude>,
* 'long' => <longitude>,
* 'title' => 'some title',
* 'desc' => 'some description',
* 'thumb' => 'some html' // an <img src=""> call or else.
* )
* );
*
* If you use html for title, desc or thumb be sure to use double quotes for attributes to avoid JS conflicts.
* For several markers add more arrays to the array.
*
* If you neither pass $geodata, an object or there is no current image/album you can still display a map.
* But in this case you need to set the $center and $fitbounds properties manually before printing a map.
*
* @global string $_zp_gallery_page
* @param array $geodata Array as noted above if no current image or album should be used
* @param obj Image or album object If set this object is used and $geodatat is ignored if set as well
*/
function __construct($geodata = NULL, $obj = NULL) {
global $_zp_gallery_page, $_zp_current_image, $_zp_current_album;
if (is_object($obj)) {
if (isImageClass($obj)) {
$this->obj = $obj;
$this->mode = 'single';
} else if (isAlbumClass($obj)) {
$this->obj = $obj;
$this->mode = 'cluster';
}
} else {
if (is_array($geodata)) {
if (count($geodata) < 1) {
$this->mode = 'single';
} else {
$this->mode = 'cluster';
}
$this->geodata = $geodata;
} else {
switch ($_zp_gallery_page) {
case 'image.php':
$this->obj = $_zp_current_image;
$this->mode = 'single';
break;
case 'album.php':
$this->obj = $_zp_current_album;
$this->mode = 'cluster';
$this->markerpopup_thumb = getOption('osmap_markerpopup_thumb');
case 'search.php':
$this->mode = 'cluster';
$this->markerpopup_thumb = getOption('osmap_markerpopup_thumb');
break;
}
}
}
$this->center = $this->getCenter();
$this->fitbounds = $this->getFitBounds();
$this->geodata = $this->getGeoData();
$this->width = getOption('osmap_width');
$this->height = getOption('osmap_height');
$this->zoom = getOption('osmap_zoom');
$this->minzoom = getOption('osmap_minzoom');
$this->maxzoom = getOption('osmap_maxzoom');
$this->maptiles = $this->tileproviders[getOption('osmap_maptiles')];
$this->clusterradius = getOption('osmap_clusterradius');
$this->markerpopup = getOption('osmap_markerpopup');
$this->controlpos = getOption('osmap_controlpos');
$this->showscale = getOption('osmap_showscale');
$this->showcursorpos = getOption('osmap_showcursorpos');
}
/**
* Assigns the needed JS and CSS
*/
static function scripts() {
?>
<link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/leaflet.css" />
<link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/MarkerCluster.css" />
<link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/MarkerCluster.Default.css" />
<link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/zp_openstreetmap.css" />
<link rel="stylesheet" type="text/css" href="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/L.Control.MousePosition.css" />
<script src="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/leaflet.js"></script>
<script src="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/leaflet.markercluster.js"></script>
<script src="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/tile-definitions.js"></script>
<script src="<?php echo FULLWEBPATH . '/' . USER_PLUGIN_FOLDER; ?>/zp_openstreetmap/L.Control.MousePosition.js"></script>
<?php
}
/**
* $returns coordinate informations for an image
* Adapted from the offical Zenphoto GoogleMap plugin by Stephen Billard (sbillard) & Vincent Bourganel (vincent3569)
* @param $image image object
*/
static function getImageGeodata($image) {
$result = array();
if (isImageClass($image)) {
$exif = $image->getMetaData();
if ((!empty($exif['EXIFGPSLatitude'])) && (!empty($exif['EXIFGPSLongitude']))) {
$lat_c = explode('.', str_replace(',', '.', $exif['EXIFGPSLatitude']) . '.0');
$lat_f = round((float) abs($lat_c[0]) + ($lat_c[1] / pow(10, strlen($lat_c[1]))), 12);
if (strtoupper(@$exif['EXIFGPSLatitudeRef']{0}) == 'S') {
$lat_f = -$lat_f;
}
$long_c = explode('.', str_replace(',', '.', $exif['EXIFGPSLongitude']) . '.0');
$long_f = round((float) abs($long_c[0]) + ($long_c[1] / pow(10, strlen($long_c[1]))), 12);
if (strtoupper(@$exif['EXIFGPSLongitudeRef']{0}) == 'W') {
$long_f = -$long_f;
}
$thumb = "<a href='" . $image->getLink() . "'><img src='" . $image->getThumb() . "' alt='' /></a>";
$result = array(
'lat' => $lat_f,
'long' => $long_f,
'title' => shortenContent(js_encode($image->getTitle()),50,'...').'<br />',
'desc' => shortenContent(js_encode($image->getDesc()),100,'...'),
'thumb' => $thumb
);
}
}
return $result;
}
/**
* Gathers the map data for an album
* Adapted from the offical Zenphoto GoogleMap plugin by Stephen Billard (sbillard) & Vincent Bourganel (vincent3569)
* @param $album album object
*/
static function getAlbumGeodata($album) {
$result = array();
$images = $album->getImages(0, 0, null, null, false);
foreach ($images as $an_image) {
$image = newImage($album, $an_image);
$imggeodata = self::getImageGeodata($image);
if(!empty($imggeodata)) {
$result[] = $imggeodata;
}
}
return $result;
}
/**
* Extracts the geodata from an image or the images of an album
* and creates the JS arrays for leaflet including title, description and thumb if set.
* @return array
*/
function getGeoData() {
global $_zp_current_image, $_zp_current_album;
$geodata = array();
if (!is_null($this->geodata)) {
return $this->geodata;
}
switch ($this->mode) {
case 'single':
$imggeodata = self::getImageGeodata($this->obj);
if(!empty($imggeodata)) {
$geodata = array($imggeodata);
}
break;
case 'cluster':
$albgeodata = self::getAlbumGeodata($this->obj);
if(!empty($albgeodata)) {
$geodata = $albgeodata;
}
break;
}
if (empty($geodata)) {
return NULL;
} else {
return $this->geodata = $geodata;
}
}
/**
* Processes the geodata returned by getGeoData() and formats it to a string
* presenting a multidimensional Javascript array for use with leafletjs
* @return string
*/
function getGeoDataJS() {
if (!is_null($this->geodatajs)) {
return $this->geodatajs;
}
$geodata = $this->getGeoData();
if(!empty($geodata)) {
$count = -1;
$js_geodata = '';
foreach ($geodata as $geo) {
$count++;
$js_geodata .= ' geodata[' . $count . '] = {
lat : "' . $geo['lat'] . '",
long : "' . $geo['long'] . '",
title : "' . shortenContent($geo['title'],50,'...') . '",
desc : "' . shortenContent($geo['desc'],100,'...') . '",
thumb : "' . $geo['thumb'] . '"
};';
}
return $this->geodatajs = $js_geodata;
}
}
/**
* Returns the bounds the map should fit based on the geodata of an image or images of an album
* @return array
*/
function getFitBounds() {
if (!is_null($this->fitbounds)) {
return $this->fitbounds;
}
$geodata = $this->getGeoData();
if (!empty($geodata)) {
$geocount = count($geodata);
$bounds = '';
$count = '';
foreach ($geodata as $g) {
$count++;
$bounds .= '[' . $g['lat'] . ',' . $g['long'] . ']';
if ($count < $geocount) {
$bounds .= ',';
}
}
$this->fitbounds = $bounds;
}
return $this->fitbounds;
}
/**
* Returns the center point of the map. On an single image it is the marker of the image itself.
* On images from an album it is calculated from their geodata
* @return array
*/
function getCenter() {
//$this->center = array(53.18, 10.38); //demotest
if (!is_null($this->center)) {
return $this->center;
}
$geodata = $this->getGeoData();
if(!empty($geodata)) {
switch ($this->mode) {
case 'single':
$this->center = array($geodata[0]['lat'], $geodata[0]['long']);
break;
case 'cluster':
//for demo tests only needs to be calculated properly later on!
$this->center = array($geodata[0]['lat'], $geodata[0]['long']);
break;
}
}
return $this->center;
}
/**
* Prints the required HTML and JS for the map
*/
function printMap() {
$class = '';
if (!empty($this->class)) {
$class = ' class="' . $this->class . '"';
}
$geodataJS = $this->getGeoDataJS();
?>
<div id="osm_map<?php echo $this->mapnumber; ?>"<?php echo $class; ?> style="width:<?php echo $this->width; ?>; height:<?php echo $this->height; ?>;"></div>
<script>
var geodata = new Array();
<?php echo $geodataJS; ?>
var map = L.map('osm_map<?php echo $this->mapnumber; ?>', {
center: [<?php echo $this->center[0]; ?>,<?php echo $this->center[1]; ?>],
zoom: <?php echo $this->zoom; ?>, //option
zoomControl: false, // disable so we can position it below
minZoom: <?php echo $this->minzoom; ?>,
maxZoom: <?php echo $this->maxzoom; ?>,
layers: [<?php echo $this->maptiles; ?>] //option => prints variable name stored in tile-definitions.js
});
<?php
if($this->mode == 'cluster' && $this->fitbounds) {
?>
map.fitBounds([<?php echo $this->fitbounds; ?>]);
<?php } ?>
<?php if($this->showscale) { ?>
L.control.scale().addTo(map);
<?php } ?>
L.control.zoom({position: '<?php echo $this->controlpos; ?>'}).addTo(map);
<?php if($this->showcursorpos) { ?>
L.control.mousePosition().addTo(map);
<?php } ?>
<?php
if($this->showmarkers && !empty($geodataJS)) {
switch ($this->mode) {
case 'single':
?>
var marker = L.marker([geodata[0]['lat'], geodata[0]['long']]).addTo(map); // from image
<?php
break;
case 'cluster':
?>
var markers_cluster = new L.MarkerClusterGroup({ maxClusterRadius: <?php echo $this->clusterradius; ?> }); //radius > Option
$.each(geodata, function (index, value) {
var text = '';
<?php if ($this->markerpopup) { ?>
text = value.title;
<?php if ($this->markerpopup_thumb) { ?>
text += value.thumb;
<?php } ?>
text += value.desc;
<?php } ?>
if (text === '') {
markers_cluster.addLayer(L.marker([value.lat, value.long]));
} else {
markers_cluster.addLayer(L.marker([value.lat, value.long]).bindPopup(text));
}
});
map.addLayer(markers_cluster);
<?php
break;
}
}
?>
</script>
<?php
}
}
// osm class end
/**
* Template function wrapper for the zpOpenStreetMap class to show a map with geodata markers
* for the current image or collected the images of an album.
*
* The map is not shown if there is no geodata available.
*
* @global obj $_zp_current_album
* @global obj $_zp_current_image
* @global string $_zp_gallery_page
* @param array $geodata Array of the geodata to create and display markers. See the constructor of the zpOpenStreetMap Class for the require structure
* @param string $width Width with unit, e.g. 100%, 100px, 100em
* @param string $height Height with unit, e.g. 100px, 100em
* @param array $mapcenter geodata array(lat,lng);
* @param int $zoom Number of the zoom 0 -
* @param array $fitbounds geodata array('min' => array(lat,lng), 'max => array(lat,lng))
* @param string $class Class name to attach to the map element
* @param int $mapnumber If calling more than one map per page an unique number is required
* @param obj $obj Image or album object to skip current image or album and also $geodata
*/
function printOpenStreetMap($geodata = NULL, $width = NULL, $height= NULL, $mapcenter = NULL, $zoom = NULL, $fitbounds = NULL, $class = '', $mapnumber = NULL,$obj = NULL) {
global $_zp_current_album, $_zp_current_image, $_zp_gallery_page;
if (!empty($class)) {
$class = ' class="' . $class . '"';
}
$map = new zpOpenStreetMap($geodata,$obj);
if (!is_null($width)) {
$map->width = $width;
}
if (!is_null($height)) {
$map->height = $height;
}
if (!is_null($mapcenter)) {
$map->center = $mapcenter;
}
if (!is_null($zoom)) {
$map->zoom = $zoom;
}
if (!is_null($fitbounds)) {
$map->fitbounds = $fitbounds;
}
if (!is_null($class)) {
$map->class = $class;
}
if (!is_null($mapnumber)) {
$map->mapnumber = $mapnumber;
}
$map->printMap();
}