// init cache $cache = null; // get map center coordinates $center = modYOOmapsHelper::locate($google_api_key, $location, $cache); if (!$center) { echo "<div class=\"alert\"><strong>Unable to get map center coordinates, please verify your location! (" . $location . ")</strong></div>\n"; return; } // css parameters $maps_id = 'yoo-maps-' . $GLOBALS['yoo_maps']; $css_module_width = 'width: ' . $module_width . 'px;'; $css_module_height = 'height: ' . $module_height . 'px;'; // js parameters $messages = array(); $maps_var = 'yoomap' . $GLOBALS['yoo_maps']; $javascript = "var {$maps_var} = new YOOmaps('" . $maps_id . "', { lat:" . $center['lat'] . ", lng:" . $center['lng'] . ", popup: " . $marker_popup . ", text: '" . modYOOmapsHelper::stripText($marker_text) . "', zoom: " . $zoom_level . ", mapCtrl: " . $map_controls . ", zoomWhl: " . $scroll_wheel_zoom . ", mapType: " . $map_type . ", typeCtrl: " . $type_controls . ", overviewCtrl: " . $overview_controls . ", directions: " . $directions . ", directionsDestUpdate: " . $directions_dest_up . ", locale: '" . $locale . "', mainIcon:'" . $main_icon . "', otherIcon:'" . $other_icon . "', msgFromAddress: '" . $from_address . "', msgGetDirections: '" . $get_directions . "', msgEmpty: '" . $empty . "', msgNotFound: '" . $not_found . "', msgAddressNotFound: '" . $address_not_found . "' });"; for ($i = 0; $i < $items; $i++) { if (array_key_exists($i, $list)) { if ($coordinates = modYOOmapsHelper::locate($google_api_key, $list[$i]->title, $cache)) { $javascript .= "{$maps_var}.addMarkerLatLng(" . $coordinates['lat'] . ", " . $coordinates['lng'] . ", '" . modYOOmapsHelper::stripText($list[$i]->introtext) . "');"; } else { $messages[] = $list[$i]->title . $not_found; } } } $javascript = "window.addEvent('load', function() { " . $javascript . " });"; require JModuleHelper::getLayoutPath('mod_yoo_maps', 'default'); $document =& JFactory::getDocument(); $document->addScript('http://maps.google.com/maps?file=api&v=2&key=' . $google_api_key); $document->addScript($module_base . 'mod_yoo_maps.js'); echo "<script type=\"text/javascript\" defer=\"defer\">\n// <!--\n{$javascript}\n// -->\n</script>\n";