'); // Add ArcGIS js API drupal_add_js($base_url .'/sites/all/libraries/google-maps-utility-library-v3/arcgislink/src/arcgislink_compiled.js'); drupal_add_js($base_url .'/sites/all/libraries/gmap_arcgis_js/gmap_arcgis.js'); // Setup Map Id drupal_add_js(array('gmap_arcgis' => array('id' => $map['id'])), 'setting'); // Add custom js $gmap_arcgis_path = drupal_get_path('module', 'gmap_arcgis') . '/'; drupal_add_js($gmap_arcgis_path . 'gmap_arcgis.js'); // TODO: move somewhere else //jquery_ui_add('ui.dialog'); jquery_ui_add('effects.fold'); jquery_ui_add('effects.explode'); jquery_ui_add('effects.core'); jquery_ui_add('ui.slider'); $path_ui_css = drupal_get_path('module', 'jquery_ui'); drupal_add_css($path_ui_css . '/jquery.ui/themes/default/ui.all.css'); } } } /** * Set the title of the marker. * * @param array $marker */ function add_title_on_marker(&$marker) { if (!empty($marker['text'])) { $dom = new DOMDocument(); $dom->loadHTML($marker['text']); //$dom->preserveWhiteSpace = false; $divs = $dom->getElementsByTagName('div'); if ($divs) { foreach ($divs AS $div) { if ($div->getAttribute('id') === 'nid') { $x = node_load($div->nodeValue); $titulo = $x->field_categoria[0]['value'] .' '. $x->field_preposicao[0]['value'] . ' ' . $x->title; $marker['opts'] = array('title' => $titulo, 'nid' => $div->nodeValue, 'category' => 'marker_uc'); } } } } } /** * Wrapper to add custom markers on map. Need to be out somewhere * @param array marker */ function __addMarker(&$map, $data) { $map['markers'][] = array( 'latitude' => $data['latitude'], 'longitude' => $data['longitude'], 'markername' => $data['markername'], 'offset' => $data['offset'], 'text' => $data['body'], 'opts' => array( 'title' => $data['title'], 'nid' => $data['nid'], 'category' => $data['category'], ), ); } /** * Implementation of hook_block(). */ function gmap_arcgis_block($op='list', $delta=0, $edit=array()) { global $map; switch ($op) { case 'list': $blocks[0]['info'] = t('Protected areas list'); return $blocks; case 'view': $blocks['subject'] = t('Protected areas list'); $blocks['content'] = drupal_get_form('uc_form') . '
X
'; return $blocks; case 'configure': case 'save': } } /** * Implementation of hook_menu(). */ function gmap_arcgis_menu() { $items['gmap_arcgis/mapserver'] = array( 'title' => 'MapServer Proxy', 'description' => 'Caches requests to a MapServer', 'page callback' => 'gmap_arcgis_mapserver', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Menu callback. * * Caches dynamic ArcGIS requests by ignoring the timestamp pattern. */ function gmap_arcgis_mapserver() { header('Content-Type: text/plain;charset=utf-8'); // The ArcGIS server URL. $base = 'http://gis2.socioambiental.org:8399/arcgis/rest/services/'; // The dynamic pattern we want to exclude. $pattern = '/_[0-9]*._callback/'; $dynamic = FALSE; $request = $_SERVER['QUERY_STRING']; $query = str_replace('q=gmap_arcgis/mapserver/', '', $request); $query = preg_replace('/&/', '?', $query, 1); $dest = $base . $query; $process = curl_init($dest); if (preg_match($pattern, $dest, $timestamp) == 1) { $dynamic = TRUE; $key = sha1(preg_replace($pattern, '', $dest)); } else { $key = sha1($dest); } $data = cache_get($key, 'cache_page'); if ($data == 0) { curl_setopt($process, CURLOPT_TIMEOUT, 30); curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE); $return = curl_exec($process); curl_close($process); cache_set($key, $return, 'cache_page', CACHE_TEMPORARY); } else { $return = $dynamic == TRUE ? preg_replace($pattern, $timestamp[0], $data->data) : $data->data; // Cache expiration. if ($data->created < time() - 3600) { cache_clear_all($key, 'cache_page'); } } echo $return; exit; }