/** * Output OpenLayers Library powered map_init() function for multi-point venues map. Uses map_locations() for pin locations cache. * @param string $lat Latitude for embedded map centerpoint. * @param string $lon Longitude for embedded map centerpoint. * @param string $pin_icon URL of pushpin icon image file. * @param array $venues [optional] Array of Venues for uncached multi-pushpin maps. Default:NULL * @since 2.1.0 * @version 2.2.0 * @return void */ function olayers_venues_init($lat, $lon, $pin_icon, $venues = array()) { global $hc_cfg, $hc_lang_core, $hc_lang_locations; $cached = count($venues) == 0 ? true : false; $pin_icon = $pin_icon == '' ? CalRoot . '/img/pins/pushpin.png' : $pin_icon; $layers = olayers_get_baselayers($lat, $lon, $hc_cfg[94]); echo ' OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3; OpenLayers.ImgPath = "' . $hc_cfg['OLImages'] . '"; var map, markers, marker, layer, popup, cur_popup, meLonLat, mapLonLat; var omarkers = []; function map_init(){ map = new OpenLayers.Map("map_canvas", { controls: [ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoom' . ($cached ? 'Bar' : '') . '(), new OpenLayers.Control.LayerSwitcher(), new OpenLayers.Control.Attribution(), new OpenLayers.Control.KeyboardDefaults() ' . ($hc_cfg[94] != 3 ? ', new OpenLayers.Control.ScaleLine()' : '') . ' ]});' . $layers . ' markers = new OpenLayers.Layer.Markers("' . $hc_lang_core['EventVenues'] . '"); map.addLayer(markers); map.setCenter(mapLonLat,' . map_zoom(0) . '); map_add_venues(locations); } function map_add_venues(locations){ for(var i = 0; i < locations.length; i++) { if(locations[i] != undefined){ var location = locations[i]; lonLat = new OpenLayers.LonLat(location[3],location[2]).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()); map_create_marker(lonLat, \'<div class="iw"><div class="iw_menu">' . map_infowindow_menu() . '</div><b>\'+location[1]+\'</b><br />\'+map_set_iw(location)+\'</div>\',location[0]); } } } function map_create_marker(lonLat, popupContent, locID) { var size = new OpenLayers.Size(32,37); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon(\'' . $pin_icon . '\',size,offset); var feature = new OpenLayers.Feature(markers, lonLat); feature.closeBox = true; feature.popupClass = OpenLayers.Class(OpenLayers.Popup.FramedCloud, {\'autoSize\': true}); feature.data.popupContentHTML = popupContent; feature.data.overflow = "hidden"; feature.data.icon = icon; var marker = feature.createMarker(); marker.events.register("mousedown", feature, function (evt) { ' . ($cached ? ' if(cur_popup != null && cur_popup.visible()) cur_popup.hide(); if (this.popup == null) { this.popup = this.createPopup(this.closeBox); map.addPopup(this.popup); this.popup.show(); } else { this.popup.toggle(); } cur_popup = this.popup; OpenLayers.Event.stop(evt);' : ' window.open("' . CalRoot . '/index.php?com=location&lID="+locID,"_blank"); OpenLayers.Event.stop(evt);') . ' }); markers.addMarker(marker); } function map_reset(){ map.setCenter(mapLonLat,' . map_zoom(0) . '); if(cur_popup != null && cur_popup.visible()) cur_popup.hide(); } function map_near_me(){ if (navigator.geolocation) { go = 1; function found(position){ var size = new OpenLayers.Size(32,37); var offset = new OpenLayers.Pixel(-(size.w/2), -size.h); var icon = new OpenLayers.Icon(\'' . CalRoot . '/img/pins/me.png\',size,offset); me = new OpenLayers.Layer.Markers("' . $hc_lang_core['NearMe'] . '"); map.addLayer(me); meLonLat = new OpenLayers.LonLat(position.coords.longitude,position.coords.latitude).transform(new OpenLayers.Projection("EPSG:4326"),map.getProjectionObject()); me.addMarker(new OpenLayers.Marker(meLonLat,icon)); map.setCenter(meLonLat,15); document.getElementById("me_link").innerHTML = "' . $hc_lang_locations['ButtonMe'] . '"; } function lost(){ document.getElementById("me_link").innerHTML = "' . $hc_lang_locations['ButtonMe'] . '"; alert("' . $hc_lang_locations['NoNearMe'] . '"); } if(meLonLat == undefined){ document.getElementById("me_link").innerHTML = "' . $hc_lang_locations['ButtonMeWorking'] . '"; navigator.geolocation.getCurrentPosition(found, lost); } else { map.setCenter(meLonLat,15); } } else { alert("' . $hc_lang_locations['CantNearMe'] . '"); } } '; if (count($venues) == 0) { map_locations(); map_shared_js(); } else { echo ' var locations = ' . json_encode($venues) . '; function map_set_iw(loc){ var iw = ""; return iw; }'; } }
<?php /** * @package Helios Calendar * @license GNU General Public License version 2 or later; see LICENSE */ define('isHC', true); define('isAction', true); include '../loader.php'; include HCLANG . '/public/syndication.php'; include HCLANG . '/public/locations.php'; include HCPATH . HCINC . '/functions/locations.php'; include HCPATH . HCINC . '/functions/maps.php'; if ($hc_cfg[69] == 0) { exit; } echo "\r\nvar map;\r\nvar gmarkers = [];\r\nvar infowindow;\r\nvar loc_list;\r\nvar center = new google.maps.LatLng(" . $hc_cfg[42] . ", " . $hc_cfg[43] . ");\r\n\r\nfunction HomeControl(controlDiv, map){\r\n\tcontrolDiv.style.padding = '5px';\r\n\tvar controlUI = document.createElement('DIV');\r\n\t\tcontrolUI.id = 'pb_button';\r\n\t\tcontrolUI.title = '" . $hc_lang_synd['Powered'] . " Helios Calendar';\r\n\t\tcontrolDiv.appendChild(controlUI);\r\n\tvar controlText = document.createElement('DIV');\r\n\t\tcontrolText.innerHTML = '" . $hc_lang_synd['Visit'] . "';\r\n\t\tcontrolUI.appendChild(controlText);\r\n\tgoogle.maps.event.addDomListener(controlUI, 'click', function() {\r\n\t\twindow.location.href = '" . CalRoot . "';\r\n\t\t});\r\n}\r\n\r\nfunction initialize() {\r\n\tvar myOptions = {\r\n\t\tzoom: " . $hc_cfg[41] . ",\r\n\t\tcenter: center,\r\n\t\tmapTypeId: google.maps.MapTypeId.ROADMAP,\r\n\t\tmapTypeControl: true,\r\n\t\tmapTypeControlOptions: {\r\n\t\t\tstyle: google.maps.MapTypeControlStyle.DROPDOWN_MENU\r\n\t\t},\r\n\t\tscaleControl: true,\r\n\t\tscaleControlOptions: {\r\n\t\t\tposition: google.maps.ControlPosition.BOTTOM_LEFT\r\n\t\t},\r\n\t\tzoomControl: true,\r\n\t\tzoomControlOptions: {\r\n\t\t\tstyle: google.maps.ZoomControlStyle.SMALL,\r\n\t\t\tposition: google.maps.ControlPosition.TOP_LEFT\r\n\t\t}};\r\n\tmap = new google.maps.Map(document.getElementById('map_canvas'), myOptions);\r\n\tsetMarkers(map, locations);\r\n\tinfowindow = new google.maps.InfoWindow({content: ''});\r\n\tvar homeControlDiv = document.createElement('DIV');\r\n\tvar homeControl = new HomeControl(homeControlDiv, map);\r\n\thomeControlDiv.index = 1;\r\n\tmap.controls[google.maps.ControlPosition.TOP_RIGHT].push(homeControlDiv);\r\n}"; map_locations(); echo "\r\nfunction setMarkers(map, markers) {\r\n\tfor (var i = 0; i < markers.length; i++) {\r\n\t\tif(markers[i] != undefined){\r\n\t\t\tvar location = markers[i];\r\n\t\t\tvar siteLatLng = new google.maps.LatLng(location[2], location[3]);\r\n\t\t\tvar marker = new google.maps.Marker({\r\n\t\t\t\tposition: siteLatLng,\r\n\t\t\t\tmap: map,\r\n\t\t\t\ttitle: location[1],\r\n\t\t\t\thtml: '<div class=\"iw\"><div class=\"iw_menu\">" . map_infowindow_menu() . "</div><span class=\"name\">'+location[1]+'</span>'+setIW(location)+'</div>',\r\n\t\t\t\ticon: '" . CalRoot . "/img/pins/default.png'\r\n\t\t\t\t});\r\n\t\t\tgoogle.maps.event.addListener(marker, 'click', function(){\r\n\t\t\t\tinfowindow.setContent(this.html);\r\n\t\t\t\tinfowindow.open(map, this);\r\n\t\t\t});\r\n\r\n\t\t\tgmarkers.push(marker);\r\n\t\t}\r\n\t}\r\n}\r\nfunction setIW(loc){\r\n\tvar iw = (loc[5] != '') ? '<span class=\"address\">' + loc[5] + '</span>' : '';\r\n\tiw += (loc[6] != '') ? '<span class=\"address2\">'+loc[6]+'</span>' : '';\r\n\tiw += (loc[7] != '') ? '<span class=\"city\">'+loc[7]+'</span>' : '';\r\n\tiw += (loc[8] != '') ? '<span class=\"region\">'+loc[8]+'</span>' : '';\r\n\tiw += (loc[10] != '') ? '<span class=\"postal\">'+loc[10]+'</span>' : '';\r\n\tiw += (loc[9] != '') ? '<span class=\"country\">'+loc[9]+'</span>' : '';\r\n\tiw += (loc[13] == 1) ? '<span class=\"website\">" . $hc_lang_synd['Website'] . " <a href=\"" . CalRoot . "/link/index.php?tID=4&oID='+loc[0]+'\" target=\"_blank\">" . $hc_lang_synd['ClickToVisit'] . "</a></span>' : '';\r\n\tiw += (loc[14] != '') ? '<span class=\"phone\">" . $hc_lang_synd['Phone'] . " '+loc[14]+'</span>' : '';\r\n\tiw += (loc[2] != '' && loc[3] != '') ? '<span class=\"geo\">'+loc[2]+', '+loc[3]+'</span>' : '';\r\n\tiw += (loc[11] != '') ? '<span class=\"events\">" . $hc_lang_synd['EventCnt'] . " '+loc[11]+'</span>' : '<span class=\"events\">" . $hc_lang_synd['EventCnt'] . " 0</span>';\r\n\tiw += (loc[12] != '') ? '<span class=\"next\">" . $hc_lang_synd['Next'] . " '+loc[12]+'</span>' : '';\r\n\treturn iw;\r\n}\r\nfunction showIW(loc){\r\n\tmap.setZoom(16);\r\n\tgoogle.maps.event.trigger(gmarkers[loc], 'click');\r\n}";