googleMapAPI_PMPro

The XML Google Maps googleMapAPI PMPro class.

Defined (1)

The class is defined in the following location(s).

/xmlgooglemaps_googleMapsAPI.php  
  1. class googleMapAPI_PMPro { 
  2.  
  3. var $api_key = ""; 
  4. var $map_id = ""; 
  5. var $width = "500px"; 
  6. var $height = "500px"; 
  7. var $map_type = "G_MAP_TYPE"; 
  8. var $markers = array(); 
  9. var $polylines = array(); 
  10. var $max_lon = -1000000; 
  11. var $min_lon = 1000000; 
  12. var $max_lat = -1000000; 
  13. var $min_lat = 1000000; 
  14. var $center_lat = 46.77429; 
  15. var $center_lon = 7.57164; 
  16. var $start_filter = 1; 
  17. var $panzoomcontrol = "GLargeMapControl"; 
  18. var $maptypecontrol = "GMapTypeControl"; 
  19. var $overviewmap = ""; 
  20. var $scalecontrol = ""; 
  21. var $zoom = 0; 
  22. var $deltazoom = 0; 
  23. var $maptypecontrolprops = array(); 
  24. var $dragging = "enable"; 
  25. var $doubleclickzoom = "enable"; 
  26. var $continuouszoom = "enable"; 
  27. var $scrollwheelzoom = "enable"; 
  28. var $googlebar = "disable"; 
  29. var $icons = array(); 
  30.  
  31.  
  32. function googleMapAPI_PMPro($api_key, $map_type="map") { 
  33. //Default Values 
  34. $this->map_id = "map".md5(uniqid(rand())); 
  35. $this->setMapTypeControlButton("G_NORMAL_MAP", "show"); 
  36. $this->setMapTypeControlButton("G_HYBRID_MAP", "show"); 
  37. $this->setMapTypeControlButton("G_SATELLITE_MAP", "show"); 
  38. $this->setMapTypeControlButton("G_PHYSICAL_MAP", "hide"); 
  39.  
  40. $this->api_key = $api_key; 
  41. $this->setMapType($map_type); 
  42.  
  43. function setDragging($value) { 
  44. switch (strtolower($value)) { 
  45. case "disabled": 
  46. $this->dragging = "disable"; 
  47. break; 
  48. default: 
  49. $this->dragging = "enable"; 
  50. break; 
  51.  
  52. function setDoubleClickZoom($value) { 
  53. switch (strtolower($value)) { 
  54. case "disabled": 
  55. $this->doubleclickzoom = "disable"; 
  56. break; 
  57. default: 
  58. $this->doubleclickzoom = "enable"; 
  59. break; 
  60.  
  61. function setContinuousZoom($value) { 
  62. switch (strtolower($value)) { 
  63. case "disabled": 
  64. $this->continuouszoom = "disable"; 
  65. break; 
  66. default: 
  67. $this->continuouszoom = "enable"; 
  68. break; 
  69.  
  70. function setScrollWheelZoom($value) { 
  71. switch (strtolower($value)) { 
  72. case "disabled": 
  73. $this->scrollwheelzoom = "disable"; 
  74. break; 
  75. default: 
  76. $this->scrollwheelzoom = "enable"; 
  77. break; 
  78.  
  79. function setGoogleBar($value) { 
  80. switch (strtolower($value)) { 
  81. case "enabled": 
  82. $this->googlebar = "enable"; 
  83. break; 
  84. default: 
  85. $this->googlebar = "disable"; 
  86. break; 
  87.  
  88. function setPanZoomControl($value) { 
  89. switch (strtolower($value)) { 
  90. case "hide": 
  91. $this->panzoomcontrol = ""; 
  92. break; 
  93. case "small": 
  94. $this->panzoomcontrol = "GSmallMapControl"; 
  95. break; 
  96. case "zoom": 
  97. $this->panzoomcontrol = "GSmallZoomControl"; 
  98. break; 
  99. default: 
  100. $this->panzoomcontrol = "GLargeMapControl"; 
  101. break; 
  102.  
  103. function setOverviewMap($value) { 
  104. switch (strtolower($value)) { 
  105. case "show": 
  106. $this->overviewmap = "GOverviewMapControl"; 
  107. break; 
  108. default: 
  109. $this->overviewmap = ""; 
  110. break; 
  111.  
  112. function setZoom($value) { 
  113. $this->zoom = $value; 
  114.  
  115. function setDeltaZoom($value) { 
  116. $this->deltazoom = $value; 
  117.  
  118. function setScaleControl($value) { 
  119. switch (strtolower($value)) { 
  120. case "show": 
  121. $this->scalecontrol = "GScaleControl"; 
  122. break; 
  123. default: 
  124. $this->scalecontrol = ""; 
  125. break; 
  126.  
  127. function setMapTypeControl($value) { 
  128. switch (strtolower($value)) { 
  129. case "hide": 
  130. $this->maptypecontrol = ""; 
  131. break; 
  132. case "hierarchical": 
  133. $this->maptypecontrol = "GHierarchicalMapTypeControl"; 
  134. break; 
  135. default: 
  136. $this->maptypecontrol = "GMapTypeControl"; 
  137. break; 
  138.  
  139. function setMapTypeControlButton($maptype, $visible) { 
  140. $this->maptypecontrolprops[$maptype]["name"] = $maptype; 
  141. switch (strtolower($visible)) { 
  142. case "hide": 
  143. $this->maptypecontrolprops[$maptype]["visible"] = 0; 
  144. break; 
  145. default: 
  146. $this->maptypecontrolprops[$maptype]["visible"] = 1; 
  147. break; 
  148.  
  149. function setWidth($width) { 
  150. if (!preg_match('!^(\d+)(.*)$!', $width, $_match)) { 
  151. return false; 
  152.  
  153. $_width = $_match[1]; 
  154. $_type = $_match[2]; 
  155. if ($_type == '%') { 
  156. $this->width = $_width . '%'; 
  157. else { 
  158. $this->width = $_width . 'px'; 
  159.  
  160. return true; 
  161.  
  162. function setStartFilter($filter) { 
  163. if (is_numeric($filter)) { 
  164. if ($filter > 0) { 
  165. $this->start_filter=$filter; 
  166. } else { 
  167. return false; 
  168. } else { 
  169. return false; 
  170.  
  171. function setHeight($height) { 
  172. if (!preg_match('!^(\d+)(.*)$!', $height, $_match)) { 
  173. return false; 
  174.  
  175. $_height = $_match[1]; 
  176. $_type = $_match[2]; 
  177. if ($_type == '%') { 
  178. $this->height = $_height . '%'; 
  179. else { 
  180. $this->height = $_height . 'px'; 
  181.  
  182. return true; 
  183.  
  184. function setSize($width, $height) { 
  185. $this->setWidth($width); 
  186. $this->setHeight($height); 
  187.  
  188. function setMapType($type) { 
  189. switch (strtoupper($type)) { 
  190. case 'G_HYBRID_MAP': 
  191. case 'G_HYBRID_TYPE': 
  192. case 'HYBRID': 
  193. $this->map_type = 'G_HYBRID_MAP'; 
  194. break; 
  195. case 'G_SATELLITE_MAP': 
  196. case 'G_SATELLITE_TYPE': 
  197. case 'SATELLITE': 
  198. $this->map_type = 'G_SATELLITE_MAP'; 
  199. break; 
  200. case 'G_PHYSICAL_MAP': 
  201. case 'G_PHYSICAL_TYPE': 
  202. case 'PHYSICAL': 
  203. $this->map_type = 'G_PHYSICAL_MAP'; 
  204. break; 
  205. case 'G_SATELLITE_3D_MAP': 
  206. case 'G_SATELLITE_3D_TYPE': 
  207. case 'EARTH': 
  208. case '3D_SATELLITE': 
  209. $this->map_type = 'G_SATELLITE_3D_MAP'; 
  210. break; 
  211. case 'G_NORMAL_MAP': 
  212. case 'G_MAP_TYPE': 
  213. case 'MAP': 
  214. case 'NORMAL': 
  215. default: 
  216. $this->map_type = 'G_NORMAL_MAP'; 
  217. break; 
  218. $this->setMapTypeControlButton($this->map_type, "show"); 
  219.  
  220. function clear() { 
  221. $this->markers = array(); 
  222. $this->polylines = array(); 
  223. $this->max_lon = -1000000; 
  224. $this->min_lon = 1000000; 
  225. $this->max_lat = -1000000; 
  226. $this->min_lat = 1000000; 
  227. $this->center_lat = 46.77429; 
  228. $this->center_lon = 7.57164; 
  229. $this->zoom = 0; 
  230.  
  231. function addMarker($lat, $lon, $html = '', $url='', $urlaction='dblclick', $iconImage = '', $iconShadowImage = '', $iconImageSizeX=12, $iconImageSizeY=20, $iconShadowSizeX=22, $iconShadowSizeY=20, $iconAnchorX=6, $iconAnchorY=18) { 
  232. $html = str_replace('"', "'", $html); 
  233. $html = str_replace("\n", "", $html); 
  234. $html = str_replace("\r", "", $html); 
  235. $marker['lon'] = $lon; 
  236. $marker['lat'] = $lat; 
  237. $marker['html'] = $html; 
  238. $marker['url'] = $url; 
  239. if (strlen($url)==0) { 
  240. $marker['urlaction'] = "disabled"; 
  241. } else { 
  242. $marker['urlaction'] = $urlaction; 
  243. if (strlen($iconImage)>0) { 
  244. $key = $iconImage.$iconShadowImage; 
  245. $marker['iconkey'] = $key; 
  246. if (intval(array_key_exists($key, $this->icons))==0) { 
  247. $this->icons[$key]['id'] = count($this->icons); 
  248. $marker['iconid'] = $this->icons[$key]['id']; 
  249. $this->icons[$key]['image'] = $iconImage; 
  250. $this->icons[$key]['imagesizex'] = $iconImageSizeX; 
  251. $this->icons[$key]['imagesizey'] = $iconImageSizeY; 
  252. $this->icons[$key]['shadow'] = $iconShadowImage; 
  253. $this->icons[$key]['shadowsizex'] = $iconShadowSizeX; 
  254. $this->icons[$key]['shadowsizey'] = $iconShadowSizeY; 
  255. $this->icons[$key]['anchorx'] = $iconAnchorX; 
  256. $this->icons[$key]['anchory'] = $iconAnchorY; 
  257. $this->markers[] = $marker; 
  258. $this->adjustCenterCoords($marker['lon'], $marker['lat']); 
  259. return count($this->markers) - 1; 
  260.  
  261. function addPolyline($color = '', $weight = 0, $opacity = 0) { 
  262. $polyline["color"] = $color; 
  263. $polyline["weight"] = $weight; 
  264. $polyline["opacity"] = $opacity; 
  265. $this->polylines[] = $polyline; 
  266. return count($this->polylines) - 1; 
  267.  
  268. function addPolylinePoint($polyline, $lat, $lon) 
  269. $pt["lat"] = $lat; 
  270. $pt["lon"] = $lon; 
  271. $this->polylines[$polyline]["points"][] = $pt; 
  272. $this->adjustCenterCoords($pt['lon'], $pt['lat']); 
  273. return count($this->polylines[$polyline]["points"]) - 1; 
  274.  
  275. function adjustCenterCoords($lon, $lat) { 
  276. if (strlen((string)$lon) == 0 || strlen((string)$lat) == 0) { 
  277. return false; 
  278. $this->max_lon = max($lon, $this->max_lon); 
  279. $this->min_lon = min($lon, $this->min_lon); 
  280. $this->max_lat = max($lat, $this->max_lat); 
  281. $this->min_lat = min($lat, $this->min_lat); 
  282. $this->center_lon = ($this->min_lon + $this->max_lon) / 2; 
  283. $this->center_lat = ($this->min_lat + $this->max_lat) / 2; 
  284. return true; 
  285.  
  286. function clearCenterCoords() { 
  287. $this->max_lon = -1000000; 
  288. $this->min_lon = 1000000; 
  289. $this->max_lat = -1000000; 
  290. $this->min_lat = 1000000; 
  291. $this->center_lat = 46.77429; 
  292. $this->center_lon = 7.57164; 
  293.  
  294. function getHeaderScript() { 
  295. $ret .= $this->addLine('<script src="http://maps.google.com/maps?file=api&v=2&key=%s" type="text/javascript"></script>'); 
  296. return sprintf($ret, $this->api_key); 
  297.  
  298. function getKMLContentElementOnly($url) { 
  299. $kmlname = $this->map_id."geoXml"; 
  300. //Div 
  301. $ret .= $this->getCommon_FirstLines(); 
  302. //Initializing 
  303. $ret .= $this->addLine(sprintf('var %s = null;', $this->map_id), 2); 
  304. $ret .= $this->addLine(sprintf('var %s = null;', $kmlname), 2); 
  305.  
  306. //Workaraound for Showing other MapTypes than MAP 
  307.  
  308. $ret .= $this->getCommon_SetMapType(); 
  309.  
  310. //Callback after GeoLoading 
  311. $ret .= $this->addLine(sprintf('var cb_geo_%s = function() {', $this->map_id), 2); 
  312. $ret .= $this->addLine(sprintf('try {', $kmlname), 3); 
  313. if ($this->max_lon > -1000000) { 
  314. if ($this->zoom == 0) { 
  315. $ret .= $this->addLine(sprintf('var zoom = %s.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(%s, %s), new GLatLng(%s, %s)));', $this->map_id, $this->min_lat, $this->min_lon, $this->max_lat, $this->max_lon), 4); 
  316. $ret .= $this->addLine(sprintf('%s.setCenter(new GLatLng(%s, %s), zoom + %s);', $this->map_id, $this->center_lat, $this->center_lon, $this->deltazoom), 4); 
  317. } else { 
  318. $ret .= $this->addLine(sprintf('%s.setCenter(new GLatLng(%s, %s), %s);', $this->map_id, $this->center_lat, $this->center_lon, $this->zoom), 4); 
  319. } else { 
  320. if ($this->zoom == 0) { 
  321. $ret .= $this->addLine(sprintf('%s.gotoDefaultViewport(%s);', $kmlname, $this->map_id), 4); 
  322. if ($this->deltazoom != 0) { 
  323. $ret .= $this->addLine(sprintf('%s.setZoom(%s.getZoom() + %s);', $this->map_id, $this->map_id, $this->deltazoom), 4); 
  324. } else { 
  325. $ret .= $this->addLine(sprintf('%s.setCenter(%s.getDefaultCenter(), %s);', $this->map_id, $kmlname, $this->zoom), 4); 
  326.  
  327. $ret .= $this->getCommon_Controls_AddRemMapType_Behaviours(4); 
  328.  
  329. $ret .= $this->getCommon_MarkersIcons(4); 
  330.  
  331. $ret .= $this->addLine(sprintf('if (%s.loadedCorrectly()) {', $kmlname), 4); 
  332. $ret .= $this->addLine(sprintf('%s.addOverlay(%s);', $this->map_id, $kmlname), 5); 
  333. $ret .= $this->addLine(sprintf('} else {'), 4); 
  334. $ret .= $this->addLine(sprintf('throw("GGeoXML Object not loaded properly!");'), 5); 
  335. $ret .= $this->addLine(sprintf('}'), 4); 
  336. $ret .= $this->addLine(sprintf('setTimeout(smt_%s, 100);', $this->map_id, $this->map_id), 4);  
  337. $ret .= $this->addLine('} catch(err) {', 3); 
  338. $ret .= $this->addLine(sprintf('document.write("Could not load the file with the GGeoXML Object! Check the file, the Google Maps API says that there is an error! Validate your links or files with the Validators from <a href=\'http://googlegeodevelopers.blogspot.com/2008/06/new-service-released-kml-validator.html\' target=\'_blank\'>http://googlegeodevelopers.blogspot.com/2008/06/new-service-released-kml-validator.html</a> or try enter the URL to your file directly in the search field of <a href=\'http://maps.google.com\' target=\'_blank\'>http://maps.google.com</a>!<br //><br //>'.$url.'");'), 4); 
  339. $ret .= $this->addLine('}', 3); 
  340. $ret .= $this->addLine('}', 2); 
  341.  
  342. //Loading 
  343. $url = str_replace("&", "&", $url); 
  344. $ret .= $this->addLine(sprintf('function load_%s() {', $this->map_id), 2); 
  345. $ret .= $this->addLine(sprintf('%s = new GMap2(document.getElementById("%s"));', $this->map_id, $this->map_id), 3); 
  346. $ret .= $this->addLine(sprintf('%s = new GGeoXml("%s", cb_geo_%s);', $kmlname , $url, $this->map_id), 3); 
  347. $ret .= $this->addLine('}', 2); 
  348.  
  349. //Running 
  350. $ret .= $this->getCommon_Init(); 
  351.  
  352. $ret .= $this->getCommon_LastLines(); 
  353.  
  354. return $ret; 
  355.  
  356. function getContentElement() { 
  357. $ret .= $this->getCommon_FirstLines(); 
  358. $ret .= $this->addLine(sprintf('var %s = null;', $this->map_id), 2); 
  359.  
  360. $ret .= $this->getCommon_SetMapType(); 
  361.  
  362. //Loading 
  363. $ret .= $this->addLine(sprintf('function load_%s() {', $this->map_id), 2); 
  364. $ret .= $this->addLine(sprintf('%s = new GMap2(document.getElementById("%s"));', $this->map_id, $this->map_id), 3); 
  365. if ($this->zoom <= 0) { 
  366. $ret .= $this->addLine(sprintf('var zoom = %s.getBoundsZoomLevel(new GLatLngBounds(new GLatLng(%s, %s), new GLatLng(%s, %s)));', $this->map_id, $this->min_lat, $this->min_lon, $this->max_lat, $this->max_lon), 3); 
  367. $ret .= $this->addLine(sprintf('%s.setCenter(new GLatLng(%s, %s), zoom + %s);', $this->map_id, $this->center_lat, $this->center_lon, $this->deltazoom), 3); 
  368. } else { 
  369. $ret .= $this->addLine(sprintf('%s.setCenter(new GLatLng(%s, %s), %s);', $this->map_id, $this->center_lat, $this->center_lon, $this->zoom), 3); 
  370.  
  371. $ret .= $this->getCommon_Controls_AddRemMapType_Behaviours(); 
  372.  
  373. $ret .= $this->getCommon_MarkersIcons(); 
  374.  
  375. $ret .= $this->getCommon_Polylines(); 
  376.  
  377. $ret .= $this->addLine(sprintf('setTimeout(smt_%s, 100);', $this->map_id, $this->map_id), 3); 
  378. $ret .= $this->addLine('}', 2); 
  379.  
  380. //Running 
  381. $ret .= $this->getCommon_Init(); 
  382.  
  383. $ret .= $this->getCommon_LastLines(); 
  384. return $ret; 
  385.  
  386. function getCommon_Controls_AddRemMapType_Behaviours($level=3) { 
  387. $firstmaptype = $this->map_type; 
  388. $ret .= $this->addLine(sprintf('%s.addMapType(%s);', $this->map_id, $firstmaptype), $level); 
  389. foreach ($this->maptypecontrolprops as $maptypeprop) { 
  390. if (strtolower($firstmaptype) != strtolower($maptypeprop["name"])) { 
  391. if ($maptypeprop["visible"] == 1) { 
  392. $ret .= $this->addLine(sprintf('%s.addMapType(%s);', $this->map_id, $maptypeprop["name"]), $level); 
  393. } else { 
  394. $ret .= $this->addLine(sprintf('%s.removeMapType(%s);', $this->map_id, $maptypeprop["name"]), $level); 
  395.  
  396. if (strlen($this->panzoomcontrol)>0) { 
  397. $ret .= $this->addLine(sprintf('%s.addControl(new %s());', $this->map_id, $this->panzoomcontrol), $level); 
  398. if (strlen($this->overviewmap)>0) { 
  399. $ret .= $this->addLine(sprintf('%s.addControl(new %s());', $this->map_id, $this->overviewmap), $level); 
  400. if (strlen($this->scalecontrol)>0) { 
  401. $ret .= $this->addLine(sprintf('%s.addControl(new %s());', $this->map_id, $this->scalecontrol), $level); 
  402. if (strlen($this->maptypecontrol)>0) { 
  403. $ret .= $this->addLine(sprintf('%s.addControl(new %s());', $this->map_id, $this->maptypecontrol), $level); 
  404.  
  405. $ret .= $this->addLine(sprintf('%s.%sDragging();', $this->map_id, $this->dragging), $level); 
  406. $ret .= $this->addLine(sprintf('%s.%sDoubleClickZoom();', $this->map_id, $this->doubleclickzoom), $level); 
  407. $ret .= $this->addLine(sprintf('%s.%sContinuousZoom();', $this->map_id, $this->continuouszoom), $level); 
  408. $ret .= $this->addLine(sprintf('%s.%sGoogleBar();', $this->map_id, $this->googlebar), $level); 
  409. $ret .= $this->addLine(sprintf('%s.%sScrollWheelZoom();', $this->map_id, $this->scrollwheelzoom), $level); 
  410. return $ret; 
  411.  
  412. function getCommon_Init() { 
  413. //Running 
  414. $ret .= $this->addLine('if (GBrowserIsCompatible()) {', 2); 
  415. $ret .= $this->addLine(sprintf('setTimeout(load_%s, 100);', $this->map_id), 3); 
  416. $ret .= $this->addLine('} else {', 2); 
  417. $ret .= $this->addLine('document.write("Javascript must be enabled in order to use Google Maps.");', 3); 
  418. $ret .= $this->addLine('}', 2); 
  419. return $ret; 
  420.  
  421. function getCommon_SetMapType() { 
  422. //Workaraound for Showing other MapTypes than MAP 
  423. $ret .= $this->addLine(sprintf('var smt_%s = function() {', $this->map_id), 2); 
  424. $ret .= $this->addLine(sprintf('%s.setMapType(%s);', $this->map_id, $this->map_type), 3); 
  425. $ret .= $this->addLine('}', 2); 
  426. return $ret; 
  427.  
  428. function getCommon_FirstLines() { 
  429. $ret .= $this->addLine(sprintf('<div id="%s" style="width: %s; height: %s;"></div>', $this->map_id, $this->width, $this->height)); 
  430. $ret .= $this->addLine('<script type="text/javascript">'); 
  431. $ret .= $this->addLine('<!--', 1); 
  432. return $ret; 
  433.  
  434. function getCommon_LastLines() { 
  435. $ret .= $this->addLine('// -->', 1); 
  436. $ret .= $this->addLine('</script>'); 
  437. return $ret; 
  438.  
  439. function getCommon_MarkersIcons($level=3) { 
  440. foreach ($this->icons as $icon) { 
  441. $ret .= $this->addLine(sprintf('var %s_icon%s = new GIcon(G_DEFAULT_ICON);', $this->map_id, $icon['id']), $level); 
  442. $ret .= $this->addLine(sprintf('%s_icon%s.image = "%s";', $this->map_id, $icon['id'], $icon['image']), $level); 
  443. $ret .= $this->addLine(sprintf('%s_icon%s.iconSize = new GSize(%s, %s);', $this->map_id, $icon['id'], $icon['imagesizex'], $icon['imagesizey']), $level); 
  444. $ret .= $this->addLine(sprintf('%s_icon%s.iconAnchor = new GPoint(%s, %s);', $this->map_id, $icon['id'], $icon['anchorx'], $icon['anchory']), $level); 
  445. if (strlen($icon['shadow'])>0) { 
  446. $ret .= $this->addLine(sprintf('%s_icon%s.shadow = "%s";', $this->map_id, $icon['id'], $icon['shadow']), $level); 
  447. $ret .= $this->addLine(sprintf('%s_icon%s.shadowSize = new GSize(%s, %s);', $this->map_id, $icon['id'], $icon['shadowsizex'], $icon['shadowsizey']), $level); 
  448.  
  449. $markerct = 0; 
  450. foreach($this->markers as $marker) {  
  451. if (strlen($marker['iconid'])>0) { 
  452. $ret .= $this->addLine(sprintf('var %s_marker%s = new GMarker(new GLatLng(%s, %s), {icon:%s_icon%s} );', $this->map_id, $markerct, $marker["lat"], $marker["lon"], $this->map_id, $marker['iconid']), $level); 
  453. } else { 
  454. $ret .= $this->addLine(sprintf('var %s_marker%s = new GMarker(new GLatLng(%s, %s));', $this->map_id, $markerct, $marker["lat"], $marker["lon"]), $level); 
  455. $ret .= $this->addLine(sprintf('%s.addOverlay(%s_marker%s);', $this->map_id, $this->map_id, $markerct), $level); 
  456. if (strlen($marker["html"])>0) { 
  457. $ret .= $this->addLine(sprintf('%s_marker%s.bindInfoWindowHtml("%s");', $this->map_id, $markerct, $marker["html"]), $level); 
  458. if ((strtolower($marker["urlaction"]) != "disabled") && (strlen($marker["url"])>0)) { 
  459. $ret .= $this->addLine(sprintf('GEvent.addListener(%s_marker%s, "%s", function() { window.open("%s", "_blank"); });', $this->map_id, $markerct, $marker["urlaction"], $marker["url"]), $level); 
  460. }  
  461. $markerct++; 
  462. return $ret; 
  463.  
  464. function getCommon_Polylines() { 
  465. foreach($this->polylines as $polyline) { 
  466. $pointcol = null; 
  467. $pointcol = array(); 
  468. $pointcol_i = 0; 
  469. $point_i=0; 
  470. foreach($polyline["points"] as $point) { 
  471. $pointcol[$pointcol_i][$point_i][0] = $point["lat"]; 
  472. $pointcol[$pointcol_i][$point_i][1] = $point["lon"]; 
  473. $point_i++; 
  474. if ($point_i>=400) { 
  475. $pointcol_i++; 
  476. $point_i=0; 
  477. $pointcol[$pointcol_i][$point_i][0] = $point["lat"]; 
  478. $pointcol[$pointcol_i][$point_i][1] = $point["lon"]; 
  479. $point_i++; 
  480. $enc = new googleMapAPIPolylineEnc_PMPro(32, 4); 
  481. for ($i=0; $i<count($pointcol);$i++) { 
  482. $encarr = $enc->dpEncode($pointcol[$i]); 
  483. $ret .= $this->addLine(sprintf('%s.addOverlay(new GPolyline.fromEncoded({color: "%s", weight: %s, opacity: %s, points: "%s", levels: "%s", zoomFactor: %s, numLevels: %s}));', $this->map_id, $polyline["color"], $polyline["weight"], $polyline["opacity"]/100, $encarr[2], $encarr[1], 32, 4), 3); 
  484. return $ret; 
  485.  
  486. function addLine($text='', $indent = 0) { 
  487. $ret = ""; 
  488. for ($i=0;$i<$indent;$i++) { 
  489. $ret .= " "; 
  490. return $ret.$text."\n"; 
  491.