xref: /plugin/openlayersmap/syntax/olmap.php (revision 837eba2fc5a718754a456905ae9dd07661432383)
1<?php
2/*
3 * Copyright (c) 2008-2011 Mark C. Prins <mc.prins@gmail.com>
4*
5* Permission to use, copy, modify, and distribute this software for any
6* purpose with or without fee is hereby granted, provided that the above
7* copyright notice and this permission notice appear in all copies.
8*
9* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*/
17
18/**
19 * Plugin OL Maps: Allow Display of a OpenLayers Map in a wiki page.
20 *
21 * @author Mark Prins
22 */
23
24if (!defined('DOKU_INC'))
25define('DOKU_INC', realpath(dirname(__FILE__) . '/../../') . '/');
26if (!defined('DOKU_PLUGIN'))
27define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/');
28require_once (DOKU_PLUGIN . 'syntax.php');
29
30/**
31 * All DokuWiki plugins to extend the parser/rendering mechanism
32 * need to inherit from this class
33 */
34class syntax_plugin_openlayersmap_olmap extends DokuWiki_Syntax_Plugin {
35	/** defaults of the known attributes of the olmap tag. */
36	private $dflt = array (
37		'id'		=> 'olmap',
38		'width'		=> '550px',
39		'height'	=> '450px',
40		'lat'		=> 50.0,
41		'lon'		=> 5.1,
42		'zoom'		=> 12,
43		'toolbar'	=> true,
44		'statusbar'	=> true,
45		'controls'	=> true,
46		'poihoverstyle'	=> false,
47		'baselyr'	=>'OpenStreetMap',
48	 	'gpxfile'	=> '',
49 		'kmlfile'	=> '',
50		'summary'	=>''
51	);
52
53	/**
54	 * Return the type of syntax this plugin defines.
55	 * @Override
56	 */
57	function getType() {
58		return 'substition';
59	}
60
61	/**
62	 * Defines how this syntax is handled regarding paragraphs.
63	 * @Override
64	 */
65	function getPType() {
66		//normal block stack
67		return 'block';
68	}
69
70	/**
71	 * Returns a number used to determine in which order modes are added.
72	 * @Override
73	 */
74	function getSort() {
75		return 901;
76	}
77
78	/**
79	 * This function is inherited from Doku_Parser_Mode.
80	 * Here is the place to register the regular expressions needed
81	 * to match your syntax.
82	 * @Override
83	 */
84	function connectTo($mode) {
85		$this->Lexer->addSpecialPattern('<olmap ?[^>\n]*>.*?</olmap>', $mode, 'plugin_openlayersmap_olmap');
86	}
87
88	/**
89	 * handle each olmap tag. prepare the matched syntax for use in the renderer.
90	 * @Override
91	 */
92	function handle($match, $state, $pos, &$handler) {
93		// break matched cdata into its components
94		list ($str_params, $str_points) = explode('>', substr($match, 7, -9), 2);
95		// get the lat/lon for adding them to the metadata (used by geotag)
96		preg_match('(lat[:|=]\"\d*\.\d*\")',$match,$mainLat);
97		preg_match('(lon[:|=]\"\d*\.\d*\")',$match,$mainLon);
98		$mainLat=substr($mainLat[0],5,-1);
99		$mainLon=substr($mainLon[0],5,-1);
100
101		$gmap = $this->_extract_params($str_params);
102		$overlay = $this->_extract_points($str_points);
103
104		$imgUrl = "{{";
105		// choose maptype based on tag
106		if (stripos($gmap['baselyr'],'google') !== false){
107			// use google
108			$imgUrl .= $this->_getGoogle($gmap, $overlay);
109		} elseif (stripos($gmap['baselyr'],'ve') !== false){
110			// use bing
111			$imgUrl .= $this->_getBing($gmap, $overlay);
112		} elseif (stripos($gmap['baselyr'],'bing') !== false){
113			// use bing
114			$imgUrl .= $this->_getBing($gmap, $overlay);
115		} elseif (stripos($gmap['baselyr'],'mapquest') !== false){
116			// use mapquest
117			$imgUrl .=$this->_getMapQuest($gmap,$overlay);
118		} else {
119			// use http://staticmap.openstreetmap.de
120			$imgUrl .=$this->_getStaticOSM($gmap,$overlay);
121		}
122
123		// append dw specific params
124		$imgUrl .="&.png?".$gmap['width']."x".$gmap['height'];
125		$imgUrl .= "&nolink";
126		$imgUrl .= " |".$gmap['summary']." }} ";
127		// remove 'px'
128		$imgUrl = str_replace("px", "",$imgUrl);
129
130		$imgUrl=p_render("xhtml", p_get_instructions($imgUrl), $info);
131
132		$mapid = $gmap['id'];
133
134		// determine width and height (inline styles) for the map image
135		// if ($gmap['width'] || $gmap['height']) {
136		//	$style = $gmap['width'] ? 'width: ' . $gmap['width'] . ";" : "";
137		//	$style .= $gmap['height'] ? 'height: ' . $gmap['height'] . ";" : "";
138		//	$style = "style='$style'";
139		// } else {
140		//	$style = '';
141		//}
142
143		// unset gmap values for width and height - they don't go into javascript
144		// unset ($gmap['width'], $gmap['height']);
145
146		// create a javascript parameter string for the map
147		$param = '';
148		foreach ($gmap as $key => $val) {
149			$param .= is_numeric($val) ? "$key: $val, " : "$key: '" . hsc($val) . "', ";
150		}
151		if (!empty ($param)) {
152			$param = substr($param, 0, -2);
153		}
154		unset ($gmap['id']);
155
156		// create a javascript serialisation of the point data
157		$poi = '';
158		$poitable='';
159		$rowId=0;
160		if (!empty ($overlay)) {
161			foreach ($overlay as $data) {
162				list ($lat, $lon, $text, $angle, $opacity, $img) = $data;
163				$rowId++;
164				$poi .= ", {lat: $lat, lon: $lon, txt: '$text', angle: $angle, opacity: $opacity, img: '$img', rowId: $rowId}";
165				$poitable .='
166			<tr>
167				<td class="rowId">'.$rowId.'</td>
168				<td class="icon"><img src="'.DOKU_BASE.'/lib/plugins/openlayersmap/icons/'.$img.'" alt="icon" /></td>
169				<td class="lat" title="'.$this->getLang('olmapPOIlatTitle').'">'.$lat.'</td>
170				<td class="lon" title="'.$this->getLang('olmapPOIlonTitle').'">'.$lon.'</td>
171				<td class="txt">'.$text.'</td>
172			</tr>';
173			}
174			$poi = substr($poi, 2);
175		}
176		$js .= "createMap({" . $param . " },[$poi]);";
177		// unescape the json
178		$poitable = stripslashes($poitable);
179
180		return array($mapid,$js,$mainLat,$mainLon,$poitable,$gmap['summary'],$imgUrl);
181	}
182
183	/**
184	 * render html tag/output. render the content.
185	 * @Override
186	 */
187	function render($mode, &$renderer, $data) {
188		static $initialised = false; // set to true after script initialisation
189		list ($mapid, $param, $mainLat, $mainLon, $poitable, $poitabledesc, $staticImgUrl) = $data;
190
191		if ($mode == 'xhtml') {
192			$olscript = '';
193			$olEnable = false;
194			$gscript = '';
195			$gEnable = $this->getConf('enableGoogle');
196			$vscript = '';
197			$vEnable = false;
198			//$yscript = '';
199			//$yEnable = false;
200			$mqEnable = $this->getConf('enableMapQuest');
201			$osmEnable = $this->getConf('enableOSM');
202			$enableBing = $this->getConf('enableBing');
203
204			$scriptEnable = '';
205
206			if (!$initialised) {
207				$initialised = true;
208				// render necessary script tags
209				// 				$gscript = $this->getConf('googleScriptUrl');
210				// 				$gscript = $gscript ? '<script type="text/javascript" src="' . $gscript . '"></script>' : "";
211				if($gEnable){
212					$gscript ='<script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3&sensor=false"></script>';
213				}
214
215				$vscript = $this->getConf('veScriptUrl');
216				$vscript = $vscript ? '<script type="text/javascript" src="' . $vscript . '"></script>' : "";
217
218				//$yscript = $this->getConf('yahooScriptUrl');
219				//$yscript = $yscript ? '<script type="text/javascript" src="' . $yscript . '"></script>' : "";
220
221				$olscript = $this->getConf('olScriptUrl');
222				$olscript = $olscript ? '<script type="text/javascript" src="' . $olscript . '"></script>' : "";
223				$olscript = str_replace('DOKU_BASE/', DOKU_BASE, $olscript);
224
225				$scriptEnable = '<script type="text/javascript">' . "\n" . '<!--//--><![CDATA[//><!--' . "\n";
226				$scriptEnable .= $olscript ? 'olEnable = true;' : 'olEnable = false;';
227				//$scriptEnable .= $yscript ? ' yEnable = true;' : ' yEnable = false;';
228				$scriptEnable .= $vscript ? ' veEnable = true;' : ' veEnable = false;';
229				$scriptEnable .= 'gEnable = '.($gEnable ? 'true' : 'false').';';
230				$scriptEnable .= 'osmEnable = '.($osmEnable ? 'true' : 'false').';';
231				$scriptEnable .= 'mqEnable = '.($mqEnable ? 'true' : 'false').';';
232				$scriptEnable .= 'bEnable = '.($enableBing ? 'true' : 'false').';';
233				$scriptEnable .= 'bApiKey="'.$this->getConf('bingAPIKey').'";';
234				$scriptEnable .= 'OpenLayers.ImgPath = "'.DOKU_BASE.'lib/plugins/openlayersmap/lib/'.$this->getConf('olMapStyle').'/";';
235				$scriptEnable .= "\n" . '//--><!]]>' . "\n" . '</script>';
236			}
237			$renderer->doc .= "
238			$gscript
239			$vscript
240			$olscript
241			$scriptEnable";
242
243			$renderer->doc .= '
244				<div id="'.$mapid.'-static" class="olStaticMap">'.$staticImgUrl.'</div>
245				<div id="'.$mapid.'-clearer" class="clearer"><p>&nbsp;</p></div>';
246
247			// render a (hidden) table of the POI for the print and a11y presentation
248			$renderer->doc .= ' 	<div class="olPOItableSpan" id="'.$mapid.'-table-span"><table class="olPOItable" id="'.$mapid.'-table" summary="'.$poitabledesc.'" title="'.$this->getLang('olmapPOItitle').'">
249		<caption class="olPOITblCaption">'.$this->getLang('olmapPOItitle').'</caption>
250		<thead class="olPOITblHeader">
251			<tr>
252				<th class="rowId" scope="col">id</th>
253				<th class="icon" scope="col">'.$this->getLang('olmapPOIicon').'</th>
254				<th class="lat" scope="col" title="'.$this->getLang('olmapPOIlatTitle').'">'.$this->getLang('olmapPOIlat').'</th>
255				<th class="lon" scope="col" title="'.$this->getLang('olmapPOIlonTitle').'">'.$this->getLang('olmapPOIlon').'</th>
256				<th class="txt" scope="col">'.$this->getLang('olmapPOItxt').'</th>
257			</tr>
258		</thead>
259		<tfoot class="olPOITblFooter"><tr><td colspan="5">'.$poitabledesc.'</td></tr></tfoot>
260		<tbody class="olPOITblBody">'.$poitable.'</tbody>
261	</table></div>';
262			//TODO no tfoot when $poitabledesc is empty
263
264			// render inline mapscript
265			$renderer->doc .="				<script type='text/javascript'><!--//--><![CDATA[//><!--
266			    var $mapid = $param
267			   //--><!]]></script>";
268			return true;
269		} elseif ($mode == 'metadata') {
270			// render metadata if available
271			if (!(($this->dflt['lat']==$mainLat)||($thisdflt['lon']==$mainLon))){
272				// unless they are the default
273				$renderer->meta['geo']['lat'] = $mainLat;
274				$renderer->meta['geo']['lon'] = $mainLon;
275			}
276			return true;
277		}
278		return false;
279	}
280
281	/**
282	 * extract parameters for the map from the parameter string
283	 *
284	 * @param   string    $str_params   string of key="value" pairs
285	 * @return  array                   associative array of parameters key=>value
286	 */
287	private function _extract_params($str_params) {
288		$param = array ();
289		preg_match_all('/(\w*)="(.*?)"/us', $str_params, $param, PREG_SET_ORDER);
290		// parse match for instructions, break into key value pairs
291		$gmap = $this->dflt;
292		foreach ($param as $kvpair) {
293			list ($match, $key, $val) = $kvpair;
294			$key = strtolower($key);
295			if (isset ($gmap[$key])){
296				if ($key == 'summary'){
297					// preserve case for summary field
298					$gmap[$key] = $val;
299				}else {
300					$gmap[$key] = strtolower($val);
301				}
302			}
303		}
304		return $gmap;
305	}
306
307	/**
308	 * extract overlay points for the map from the wiki syntax data
309	 *
310	 * @param   string    $str_points   multi-line string of lat,lon,text triplets
311	 * @return  array                   multi-dimensional array of lat,lon,text triplets
312	 */
313	private function _extract_points($str_points) {
314		$point = array ();
315		//preg_match_all('/^([+-]?[0-9].*?),\s*([+-]?[0-9].*?),(.*?),(.*?),(.*?),(.*)$/um', $str_points, $point, PREG_SET_ORDER);
316		/*
317		group 1: ([+-]?[0-9]+(?:\.[0-9]*)?)
318		group 2: ([+-]?[0-9]+(?:\.[0-9]*)?)
319		group 3: (.*?)
320		group 4: (.*?)
321		group 5: (.*?)
322		group 6: (.*)
323		*/
324		preg_match_all('/^([+-]?[0-9]+(?:\.[0-9]*)?),\s*([+-]?[0-9]+(?:\.[0-9]*)?),(.*?),(.*?),(.*?),(.*)$/um', $str_points, $point, PREG_SET_ORDER);
325		// create poi array
326		$overlay = array ();
327		foreach ($point as $pt) {
328			list ($match, $lat, $lon, $angle, $opacity, $img, $text) = $pt;
329			$lat = is_numeric($lat) ? $lat : 0;
330			$lon = is_numeric($lon) ? $lon : 0;
331			$angle = is_numeric($angle) ? $angle : 0;
332			$opacity = is_numeric($opacity) ? $opacity : 0.8;
333			$img = trim($img);
334			// TODO validate using exist & set up default img?
335			$text = addslashes(str_replace("\n", "", p_render("xhtml", p_get_instructions($text), $info)));
336			$overlay[] = array($lat, $lon, $text, $angle, $opacity, $img);
337		}
338		return $overlay;
339	}
340
341	/**
342	 * Create a MapQuest static map API image url.
343	 * @param array $gmap
344	 * @param array $overlay
345	 */
346	private function _getMapQuest($gmap,$overlay) {
347		$sUrl=$this->getConf('iconUrlOverload');
348		if (!$sUrl){
349			$sUrl=DOKU_URL;
350		}
351		switch ($gmap['baselyr']){
352			case 'mapquest hybrid':
353				$maptype='hyb';
354				break;
355			case 'mapquest sat':
356				$maptype='sat';
357				break;
358			case 'mapquest road':
359			default:
360				$maptype='map';
361				break;
362		}
363		// TODO use bestfit option
364		// 		see: http://open.mapquestapi.com/staticmap/
365		$imgUrl = "http://open.mapquestapi.com/staticmap/v3/getmap";
366		$imgUrl .= "?center=".$gmap['lat'].",".$gmap['lon'];
367		$imgUrl .= "&size=".str_replace("px", "",$gmap['width']).",".str_replace("px", "",$gmap['height']);
368		// max level for mapquest is 16
369		if ($gmap['zoom']>16) {
370			$imgUrl .= "&zoom=16";
371		} else			{
372			$imgUrl .= "&zoom=".$gmap['zoom'];
373		}
374		// TODO mapquest allows using one image url with a multiplier $NUMBER eg:
375		// $NUMBER = 2
376		// $imgUrl .= DOKU_URL."/".DOKU_PLUGIN."/".getPluginName()."/icons/".$img.",$NUMBER,C,".$lat1.",".$lon1.",0,0,0,0,C,".$lat2.",".$lon2.",0,0,0,0";
377		if (!empty ($overlay)) {
378			$imgUrl .= "&xis=";
379			foreach ($overlay as $data) {
380				list ($lat, $lon, $text, $angle, $opacity, $img) = $data;
381				$imgUrl .= $sUrl."lib/plugins/openlayersmap/icons/".$img.",1,C,".$lat.",".$lon.",0,0,0,0,";
382			}
383			$imgUrl = substr($imgUrl,0,-1);
384		}
385		$imgUrl .= "&imageType=png&type=".$maptype;
386		dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::_getMapQuest: MapQuest image url is:');
387		return $imgUrl;
388	}
389	/**
390	 *
391	 * Create a Google maps static image url w/ the poi.
392	 * @param array $gmap
393	 * @param array $overlay
394	 */
395	private function _getGoogle($gmap, $overlay){
396		$sUrl=$this->getConf('iconUrlOverload');
397		if (!$sUrl){
398			$sUrl=DOKU_URL;
399		}
400		switch ($gmap['baselyr']){
401			case 'google hybrid':
402				$maptype='hybrid';
403				break;
404			case 'google sat':
405				$maptype='satellite';
406				break;
407			case 'google relief':
408				$maptype='terrain';
409				break;
410			case 'google road':
411			default:
412				$maptype='roadmap';
413				break;
414		}
415		// TODO use viewport / visible instead of center/zoom,
416		//		see: https://code.google.com/intl/nl/apis/maps/documentation/staticmaps/#ImplicitPositioning
417		//http://maps.google.com/maps/api/staticmap?center=51.565690,5.456756&zoom=16&size=600x400&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/marker.png|label:1|51.565690,5.456756&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/marker-blue.png|51.566197,5.458966|label:2&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/parking.png|51.567177,5.457909|label:3&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/parking.png|51.566283,5.457330|label:4&markers=icon:http://wild-water.nl/dokuwiki/lib/plugins/openlayersmap/icons/parking.png|51.565630,5.457695|label:5&sensor=false&format=png&maptype=roadmap
418		$imgUrl = "http://maps.google.com/maps/api/staticmap";
419		$imgUrl .= "?center=".$gmap['lat'].",".$gmap['lon'];
420		$imgUrl .= "&size=".str_replace("px", "",$gmap['width'])."x".str_replace("px", "",$gmap['height']);
421		// don't need this anymore $imgUrl .= "&key=".$this->getConf('googleAPIKey');
422		// max is 21 (== building scale), but that's overkill..
423		if ($gmap['zoom']>16) {
424			$imgUrl .= "&zoom=16";
425		} else			{
426			$imgUrl .= "&zoom=".$gmap['zoom'];
427		}
428
429		if (!empty ($overlay)) {
430			$rowId=0;
431			foreach ($overlay as $data) {
432				list ($lat, $lon, $text, $angle, $opacity, $img) = $data;
433				$imgUrl .= "&markers=icon%3a".$sUrl."lib/plugins/openlayersmap/icons/".$img."%7c".$lat.",".$lon."%7clabel%3a".++$rowId;
434			}
435		}
436		$imgUrl .= "&format=png&maptype=".$maptype."&sensor=false";
437		global $conf;
438		$imgUrl .= "&language=".$conf['lang'];
439		dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::_getGoogle: Google image url is:');
440		return $imgUrl;
441	}
442
443	/**
444	 *
445	 * Create a Bing maps static image url w/ the poi.
446	 * @param array $gmap
447	 * @param array $overlay
448	 */
449	private function _getBing($gmap, $overlay){
450		if(!$this->getConf('bingAPIKey')){
451			// in case there is no Bing api key
452			$this->_getMapQuest($gmap, $overlay);
453		}
454		switch ($gmap['baselyr']){
455			case 've hybrid':
456			case 'bing hybrid':
457				$maptype='AerialWithLabels';
458				break;
459			case 've sat':
460			case 'bing sat':
461				$maptype='Aerial';
462				break;
463			case 've normal':
464			case 've road':
465			case 've':
466			case 'bing road':
467			default:
468				$maptype='Road';
469				break;
470		}
471		$bbox=$this->_calcBBOX($overlay, $gmap['lat'], $gmap['lon']);
472		//http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/51.56573,5.45690/12?mapSize=400,400&key=Agm4PJzDOGz4Oy9CYKPlV-UtgmsfL2-zeSyfYjRhf57OQB_oj87j5pncKZSay5qY
473
474		//$imgUrl = "http://dev.virtualearth.net/REST/v1/Imagery/Map/".$maptype."/".$gmap['lat'].",".$gmap['lon']."/".$gmap['zoom'];
475		$imgUrl = "http://dev.virtualearth.net/REST/v1/Imagery/Map/".$maptype."/";
476		$imgUrl .= "?mapArea=".$bbox['minlat'].",".$bbox['minlon'].",".$bbox['maxlat'].",".$bbox['maxlon']."&declutter=1";
477		$imgUrl .= "&ms=".str_replace("px", "",$gmap['width']).",".str_replace("px", "",$gmap['height']);
478		// create a bing api key at https://www.bingmapsportal.com/application
479		$imgUrl .= "&key=".$this->getConf('bingAPIKey');
480		if (!empty ($overlay)) {
481			$rowId=0;
482			foreach ($overlay as $data) {
483				list ($lat, $lon, $text, $angle, $opacity, $img) = $data;
484				// TODO icon style lookup, see: http://msdn.microsoft.com/en-us/library/ff701719.aspx for iconStyle
485
486				$iconStyle=32;
487				$rowId++;
488				// NOTE: the max number of pushpins is 18!
489				if ($rowId==18) {
490					break;
491				}
492				$imgUrl .= "&pp=$lat,$lon;$iconStyle;$rowId";
493			}
494		}
495		dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::_getBing: bing image url is:');
496		return $imgUrl;
497	}
498
499	/**
500	 *
501	 * Create a static OSM map image url w/ the poi from http://staticmap.openstreetmap.de (staticMapLite)
502	 * @param array $gmap
503	 * @param array $overlay
504	 */
505	private function _getStaticOSM($gmap, $overlay){
506		//http://staticmap.openstreetmap.de/staticmap.php?center=47.000622235634,10.117187497601&zoom=5&size=500x350
507		// &markers=48.999812532766,8.3593749976708,lightblue1|43.154850037315,17.499999997306,lightblue1|49.487527053077,10.820312497573,ltblu-pushpin|47.951071133739,15.917968747369,ol-marker|47.921629720114,18.027343747285,ol-marker-gold|47.951071133739,19.257812497236,ol-marker-blue|47.180141361692,19.257812497236,ol-marker-green
508		$imgUrl = "http://staticmap.openstreetmap.de/staticmap.php";
509		$imgUrl .= "?center=".$gmap['lat'].",".$gmap['lon'];
510		$imgUrl .= "&size=".str_replace("px", "",$gmap['width'])."x".str_replace("px", "",$gmap['height']);
511		if ($gmap['zoom']>16) {
512			$imgUrl .= "&zoom=16";
513		} else			{
514			$imgUrl .= "&zoom=".$gmap['zoom'];
515		}
516
517		switch ($gmap['baselyr']){
518			case 'mapnik':
519				$maptype='mapnik';
520				break;
521			case 't@h':
522				$maptype='osmarenderer';
523				break;
524			case 'cycle map':
525				$maptype='cycle';
526				break;
527			default:
528				$maptype='';
529			break;
530		}
531		$imgUrl .= "&maptype=".$maptype;
532
533		if (!empty ($overlay)) {
534			$rowId=0;
535			$imgUrl .= "&markers=";
536			foreach ($overlay as $data) {
537				list ($lat, $lon, $text, $angle, $opacity, $img) = $data;
538				$rowId++;
539				$iconStyle = "lightblue$rowId";
540				$imgUrl .= "$lat,$lon,$iconStyle%7c";
541			}
542			$imgUrl = substr($imgUrl,0,-3);
543		}
544
545		dbglog($imgUrl,'syntax_plugin_openlayersmap_olmap::_getStaticOSM: bing image url is:');
546		return $imgUrl;
547	}
548
549	private function _calcBBOX($overlay, $lat, $lon){
550		$lats[] = $lat;
551		$lons[] = $lon;
552		foreach ($overlay as $data) {
553			list ($lat, $lon, $text, $angle, $opacity, $img) = $data;
554			$lats[] = $lat;
555			$lons[] = $lon;
556		}
557		sort($lats);
558		sort($lons);
559		return array('minlat'=>$lats[0], 'minlon'=>$lons[0], 'maxlat'=>$lats[count($lats)-1], 'maxlon'=>$lons[count($lats)-1]);
560	}
561}