diff --git a/actions/amap_maps_api/nearby_search.php b/actions/amap_maps_api/nearby_search.php new file mode 100644 index 0000000..e80d5e6 --- /dev/null +++ b/actions/amap_maps_api/nearby_search.php @@ -0,0 +1,211 @@ + 0) + $search_radius_txt = amap_ma_get_radius_string($s_radius); +else + $search_radius_txt = amap_ma_get_default_radius_search_string(); + +$s_radius = amap_ma_get_default_radius_search($s_radius); + +// retrieve coords of location asked, if any +$coords = amap_ma_geocode_location($s_location); + +$title = elgg_echo('groupsmap:all'); + + +$options = array( + "type" => "group", + "full_view" => FALSE, + 'limit' => get_input('limit', 0), + 'offset' => get_input('proximity_offset', 0), + 'count' => false +); + + +$options['metadata_name_value_pairs'][] = array('name' => 'location', 'value' => '', 'operand' => '!='); +$options['metadata_name_value_pairs'][] = array('name' => 'country', 'value' => '', 'operand' => '!='); +$options['metadata_name_value_pairs_operator'] = 'OR'; + +if ($initial_load) { + if ($initial_load == 'newest') { + $options['limit'] = amap_ma_get_initial_limit('groupsmap'); + $title = elgg_echo('groupsmap:groups:newest', array($options['limit'])); + } else if ($initial_load == 'location') { + // retrieve coords of location asked, if any + $user = elgg_get_logged_in_user_entity(); + if ($user->location) { + $s_lat = $user->getLatitude(); + $s_long = $user->getLongitude(); + + if ($s_lat && $s_long) { + $s_radius = amap_ma_get_initial_radius('groupsmap'); + $search_radius_txt = $s_radius; + $s_radius = amap_ma_get_default_radius_search($s_radius); + $options = add_order_by_proximity_clauses($options, $s_lat, $s_long); + $options = add_distance_constraint_clauses($options, $s_lat, $s_long, $s_radius); + + $title = elgg_echo('groupsmap:groups:nearby:search', array($user->location)); + } + } + } +} else { + if ($s_keyword) { + $db_prefix = elgg_get_config("dbprefix"); + $query = sanitise_string($s_keyword); + + $options["joins"] = array("JOIN {$db_prefix}groups_entity ge ON e.guid = ge.guid"); + $where = "(ge.name LIKE '%$query%' OR ge.description LIKE '%$query%')"; + $options["wheres"] = array($where); + } + + if ($coords) { + $search_location_txt = $s_location; + $s_lat = $coords['lat']; + $s_long = $coords['long']; + + if ($s_lat && $s_long) { + $options = add_order_by_proximity_clauses($options, $s_lat, $s_long); + $options = add_distance_constraint_clauses($options, $s_lat, $s_long, $s_radius); + } + $title = elgg_echo('groupsmap:groups:nearby:search', array($search_location_txt)); + } +} + +$groups = elgg_get_entities_from_metadata($options); + +$users = array(); +if (amap_ma_check_if_membersmap_gm_enabled()) { + $options1 = array('type' => 'user', 'full_view' => false); + $options1['limit'] =0; + $options1['metadata_name_value_pairs'] = array(array('name' => 'location', 'value' => '', 'operand' => '!=')); + $users = elgg_get_entities_from_metadata($options1); + $indextable .= elgg_view('input/checkbox', array( + 'name' => 'chbx_user', + 'id' => 'chbx_user', + 'checked' => true, + )).''; + + if ($users) { + foreach ($users as $entity) { + $entity = amap_ma_set_entity_additional_info($entity, 'name', 'description', $entity->location); + } + } +} + +$pages = array(); +if (amap_ma_check_if_pagesmap_gm_enabled()) { + $array4 = array(); + $options4 = array( + 'type' => 'object', + 'subtype' => array('page','page_top'), + 'full_view' => false, + 'limit' => 0, + ); + $pages = elgg_get_entities($options4); + + if ($pages) { + foreach ($pages as $entity) { + $entity = amap_ma_set_entity_additional_info($entity, 'title', 'description', $entity->location); + } + } + + $indextable .= elgg_view('input/checkbox', array( + 'name' => 'chbx_pages', + 'id' => 'chbx_pages', + 'checked' => true, + )).''; +} + + +$entities1 = array_merge($users, $groups); +$entities = array_merge($entities1, $pages); + + +$map_objects = array(); +if ($entities) { + + foreach ($entities as $entity) { + $entity = amap_ma_set_entity_additional_info($entity, 'name', 'briefdescription', groupsmap_get_group_location_str($entity)); + } + + + foreach ($entities as $e) { + if ($e->getLatitude() && $e->getLongitude()) { + $object_x = array(); + $object_x['guid'] = $e->getGUID(); + $object_x['title'] = amap_ma_remove_shits($e->getVolatileData('m_title'));; + $object_x['description'] = amap_ma_get_entity_description($e->getVolatileData('m_description')); + $object_x['location'] = elgg_echo('amap_maps_api:location', array(amap_ma_remove_shits($e->getVolatileData('m_location')))); + $object_x['lat'] = $e->getLatitude(); + $object_x['lng'] = $e->getLongitude(); + $object_x['icon'] = $e->getVolatileData('m_icon'); + $object_x['type'] = $e->getType().$e->getSubtype(); + $object_x['other_info'] = $e->getVolatileData('m_other_info'); + $object_x['map_icon'] = $e->getVolatileData('m_map_icon'); + $object_x['info_window'] = $object_x['icon'].' '.$object_x['title']; + $object_x['info_window'] .= ($object_x['location']?'
'.$object_x['location']:''); + $object_x['info_window'] .= ($object_x['other_info']?'
'.$object_x['other_info']:''); + $object_x['info_window'] .= ($object_x['description']?'
'.$object_x['description']:''); + array_push($map_objects, $object_x); + } + } + + $sidebar = ''; + if (amap_ma_check_if_add_sidebar_list('groupsmap')) { + $box_color_flag = true; + foreach ($entities as $entity) { + $sidebar .= elgg_view('groupsmap/sidebar', array('entity' => $entity, 'box_color' => ($box_color_flag ? 'box_even' : 'box_odd'))); + $box_color_flag = !$box_color_flag; + } + } +} +else { + $content = elgg_echo('amap_maps_api:search:personalized:empty'); +} + +$result = array( + 'error' => false, + 'title' => $title, + 'location' => $search_location_txt, + 'radius' => $search_radius_txt, + 's_radius' => amap_ma_get_default_radius_search($s_radius, true), + 's_radius_no' => $s_radius, + 'content' => $content, + 'map_objects' => json_encode($map_objects), + 's_location_lat' => ($s_lat? $s_lat: ''), + 's_location_lng' => ($s_long? $s_long: ''), + 's_location_txt' => $search_location_txt, + 'sidebar' => $sidebar, +); + +// release variables +unset($entities); +unset($map_objects); + +echo json_encode($result); +exit; diff --git a/lib/amap_maps_api.php b/lib/amap_maps_api.php index 9bca36f..9aadf88 100644 --- a/lib/amap_maps_api.php +++ b/lib/amap_maps_api.php @@ -1,10 +1,10 @@ 600, - ), $options); + ), $options); $objects = find_active_users($options, 0, 0); return $objects; @@ -349,7 +349,7 @@ function amap_ma_not_permit_public_access() { return false; } -// Check if membersmap is enabled for global map +// Check if membersmap is enabled for global map function amap_ma_check_if_membersmap_gm_enabled() { $gm_membersmap = trim(elgg_get_plugin_setting('gm_membersmap', AMAP_MA_PLUGIN_ID)); @@ -360,7 +360,7 @@ function amap_ma_check_if_membersmap_gm_enabled() { return false; } -// Check if groupsmap is enabled for global map +// Check if groupsmap is enabled for global map function amap_ma_check_if_groupsmap_gm_enabled() { $gm_groupsmap = trim(elgg_get_plugin_setting('gm_groupsmap', AMAP_MA_PLUGIN_ID)); @@ -371,7 +371,7 @@ function amap_ma_check_if_groupsmap_gm_enabled() { return false; } -// Check if agora is enabled for global map +// Check if agora is enabled for global map function amap_ma_check_if_agora_gm_enabled() { $gm_agora = trim(elgg_get_plugin_setting('gm_agora', AMAP_MA_PLUGIN_ID)); @@ -382,7 +382,7 @@ function amap_ma_check_if_agora_gm_enabled() { return false; } -// Check if pagesmap is enabled for global map +// Check if pagesmap is enabled for global map function amap_ma_check_if_pagesmap_gm_enabled() { $gm_pagesmap = trim(elgg_get_plugin_setting('gm_pagesmap', AMAP_MA_PLUGIN_ID)); @@ -406,7 +406,7 @@ function amap_ma_get_entity_description($desc) { $entity_description = preg_replace('/[^(\x20-\x7F)]*/', '', $desc); $entity_description = amap_ma_remove_shits($entity_description); - // code below replace the " with " from href of a tag. + // code below replace the " with " from href of a tag. // The Regular Expression filter $reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/"; // Check if there is a url in the text @@ -450,10 +450,10 @@ function amap_ma_get_entity_icon($u) { $user_icon = amap_ma_get_marker_icon('membersmap'); if ($user_icon == 'user_icon_tiny.png') { $entity_icon = $u->getIconURL('tiny'); - } + } else if ($user_icon == 'user_icon_small.png') { $entity_icon = $u->getIconURL('small'); - } + } else { $entity_icon = elgg_get_site_url() . "mod/membersmap/graphics/{$user_icon}"; } @@ -469,12 +469,12 @@ function amap_ma_get_entity_icon($u) { } else if (elgg_instanceof($u, 'object', 'lcourt')) { $entity_icon = elgg_get_simplecache_url('leaguemanager/icon/icons/stadium.png'); - } + } else if (elgg_instanceof($u, 'object', 'page') || elgg_instanceof($u, 'object', 'page_top')) { //$entity_icon = elgg_get_site_url() . 'mod/pagesmap/graphics/' . amap_ma_get_marker_icon('pagesmap'); $entity_icon = elgg_get_simplecache_url('pagesmap/icon/' . amap_ma_get_marker_icon('pagesmap')); } - + return $entity_icon; } @@ -544,7 +544,7 @@ function amap_ma_get_initial_radius($pluginname) { /** * Assign to entity additional information for showing on map - * + * * @param type $entity * @param type $etitle * @param type $edescription @@ -552,7 +552,7 @@ function amap_ma_get_initial_radius($pluginname) { * @param type $eotherinfo * @param type $m_icon_light: if need to give entity map icon opacity, set this to true * @param type $eurl: if need to use other URL than standard entity URL, set this to true - * + * * @return Elgg Entity as given */ function amap_ma_set_entity_additional_info($entity, $etitle, $edescription, $elocation = null, $eotherinfo = null, $m_icon_light = false, $eurl = false) { @@ -611,7 +611,7 @@ function amap_ma_set_entity_additional_info($entity, $etitle, $edescription, $el $entity->setVolatileData('m_other_info', $eotherinfo); } $entity->setVolatileData('m_icon_light', $m_icon_light); - + /* hide at the moment as the distance displayed is not well calculated if ($user->getLatitude() && $user->getLongitude()) { $distance = get_distance($entity->getLatitude(), $entity->getLongitude(), $user->getLatitude(), $user->getLongitude()); // distance in metres diff --git a/pages/amap_maps_api/global.php b/pages/amap_maps_api/global.php index c423eaa..dfb56b0 100644 --- a/pages/amap_maps_api/global.php +++ b/pages/amap_maps_api/global.php @@ -1,10 +1,10 @@ 'location', 'value' => '', 'operand' => '!=')); $users = elgg_get_entities_from_metadata($options1); $indextable .= elgg_view('input/checkbox', array( - 'name' => 'chbx_user', - 'id' => 'chbx_user', + 'name' => 'chbx_user', + 'id' => 'chbx_user', 'checked' => true, - )).''; - + )).''; + if ($users) { foreach ($users as $entity) { $entity = amap_ma_set_entity_additional_info($entity, 'name', 'description', $entity->location); @@ -54,17 +55,17 @@ $groups = array(); if (amap_ma_check_if_groupsmap_gm_enabled()) { - elgg_load_library('elgg:groupsmap'); + elgg_load_library('elgg:groupsmap'); $options2 = array('type' => 'group', 'full_view' => false); $options2['limit'] = 0; $options2['metadata_name_value_pairs'] = array(array('name' => 'location', 'value' => '', 'operand' => '!=')); $groups = elgg_get_entities_from_metadata($options2); $indextable .= elgg_view('input/checkbox', array( - 'name' => 'chbx_group', - 'id' => 'chbx_group', + 'name' => 'chbx_group', + 'id' => 'chbx_group', 'checked' => true, - )).''; - + )).''; + if ($groups) { foreach ($groups as $entity) { $entity = amap_ma_set_entity_additional_info($entity, 'name', 'briefdescription', groupsmap_get_group_location_str($entity)); @@ -79,16 +80,16 @@ 'subtype' => 'agora', 'limit' => 0, 'full_view' => false, - 'view_toggle_type' => false + 'view_toggle_type' => false ); $options3['metadata_name_value_pairs'] = array(array('name' => 'location', 'value' => '', 'operand' => '!=')); $ads = elgg_get_entities_from_metadata($options3); $indextable .= elgg_view('input/checkbox', array( - 'name' => 'chbx_agora', - 'id' => 'chbx_agora', + 'name' => 'chbx_agora', + 'id' => 'chbx_agora', 'checked' => true, - )).''; - + )).''; + if ($ads) { foreach ($ads as $entity) { $entity = amap_ma_set_entity_additional_info($entity, 'title', 'description'); @@ -102,66 +103,101 @@ $options4 = array( 'type' => 'object', 'subtype' => array('page','page_top'), - 'full_view' => false, + 'full_view' => false, 'limit' => 0, ); $pages = elgg_get_entities($options4); - + if ($pages) { foreach ($pages as $entity) { $entity = amap_ma_set_entity_additional_info($entity, 'title', 'description', $entity->location); } - } - + } + $indextable .= elgg_view('input/checkbox', array( - 'name' => 'chbx_pages', - 'id' => 'chbx_pages', + 'name' => 'chbx_pages', + 'id' => 'chbx_pages', 'checked' => true, - )).''; + )).''; } if (!empty($indextable)) { - $indextable = '
'.$indextable.'
'; + $indextable = '
'.$indextable.'
'; } - + $subtotal1 = array_merge($users, $groups); $subtotal2 = array_merge($subtotal1, $pages); $total = array_merge($subtotal2, $ads); -$content = elgg_view('amap_maps_api/map_box', array( - 'mapwidth'=>$mapwidth, - 'mapheight'=>$mapheight, -)); -$content .= elgg_view('amap_maps_api/map', array( - 'entities'=>$total, - 'defaultlocation'=>$defaultlocation, - 'defaultzoom'=>$mapzoom, - 'defaultcoords'=>$defaultcoords, - 'clustering'=>$clustering, - 'clustering_zoom'=>$clustering_zoom, - 'layers'=>$layers, - 'default_layer'=>$default_layer, - 'osm_base_layer' => amap_ma_get_osm_base_layer(), -)); +// print_r($total); -// locad index table only if clustering is disable as it does'not work if (!$clustering) { $content = $indextable.$content; } -$side_vars = array(); + +// get variables +$s_location = $_GET["l"]; +$s_radius = (int) $_GET["r"]; +$s_keyword = $_GET["q"]; +$showradius = $_GET["sr"]; +// get initial load option from settings +$initial_load = elgg_get_plugin_setting('initial_load', 'groupsmap'); + +if ($s_location || $s_keyword) { + $search_radius_txt = ''; + $s_radius = ($s_radius?$s_radius:AMAP_MA_DEFAULT_RADIUS); + $search_radius_txt = $s_radius; + + // retrieve coords of location asked, if any + $coords = amap_ma_geocode_location($s_location); + + if ($coords) { + $s_radius = amap_ma_get_default_radius_search($s_radius); + $search_location_txt = $s_location; + $s_lat = $coords['lat']; + $s_long = $coords['long']; + + $title = elgg_echo('groupsmap:groups:nearby:search', array($search_location_txt)); + } + + // if special params asked, then forget the initial load option from settings + $initial_load = ''; +} + +// load the search form +$body_vars = array(); +$body_vars['s_action'] = 'amap_maps_api/nearby_search'; +$body_vars['initial_location'] = $search_location_txt; +$body_vars['initial_radius'] = $search_radius_txt; +$body_vars['initial_keyword'] = $s_keyword; +$body_vars['initial_load'] = $initial_load; +if ($user->location) { + $body_vars['my_location'] = $user->location; + if (isset($initial_load) && $initial_load == 'location') { + $body_vars['initial_location'] = $user->location; + } +} +$form_vars = array('enctype' => 'multipart/form-data'); + +$content .= elgg_view_form('amap_maps_api/nearby', $form_vars, $body_vars); +$content .= elgg_view('amap_maps_api/map_box', array( + 'mapwidth' => $mapwidth, + 'mapheight' => $mapheight, +)); + +$sidebar = ''; +$layout = 'one_column'; $params = array( 'content' => $content, - 'sidebar' => '', + 'sidebar' => $sidebar, 'title' => $title, 'filter_override' => '', ); -$body = elgg_view_layout('one_column', $params); - +$body = elgg_view_layout($layout, $params); echo elgg_view_page($title, $body); - // release variables unset($users); unset($groups); @@ -170,6 +206,3 @@ unset($subtotal1); unset($subtotal2); unset($total); - - - diff --git a/views/default/admin/settings/amap_maps_api.php b/views/default/admin/settings/amap_maps_api.php index 504959d..6a2c4d6 100644 --- a/views/default/admin/settings/amap_maps_api.php +++ b/views/default/admin/settings/amap_maps_api.php @@ -1,7 +1,7 @@ elgg_echo('amap_maps_api:settings:tabs:general_options'), 'href' => '/admin/settings/amap_maps_api?tab=general_options', 'selected' => ($tab == 'general_options'), - ), -/* temporarily anavailable + ), + array( 'text' => elgg_echo('amap_maps_api:settings:tabs:global_options'), 'href' => '/admin/settings/amap_maps_api?tab=global_options', 'selected' => ($tab == 'global_options'), ), - array( + array( 'text' => elgg_echo('amap_maps_api:settings:tabs:personalized_options'), 'href' => '/admin/settings/amap_maps_api?tab=personalized_options', 'selected' => ($tab == 'personalized_options'), ), - * - */ array( 'text' => elgg_echo('amap_maps_api:settings:tabs:users_geolocation'), 'href' => '/admin/settings/amap_maps_api?tab=users_geolocation', diff --git a/views/default/amap_maps_api/amap_search.js b/views/default/amap_maps_api/amap_search.js index cf052e4..a1eabc1 100644 --- a/views/default/amap_maps_api/amap_search.js +++ b/views/default/amap_maps_api/amap_search.js @@ -2,23 +2,25 @@ define(function (require) { var elgg = require('elgg'); var $ = require('jquery'); require("amap_ma_oms_js"); - + + // Initialize map vars var map_settings = require("amap_maps_api/settings"); - var gm = google.maps; + var gm = google.maps; var map; var mapTypeIds = []; - var markers = []; + var markers = []; var markerBounds = new google.maps.LatLngBounds(); var mc; var circle = new google.maps.Circle(); - + // retrieve available map layers var layer_x = map_settings['layers']; $.each($.parseJSON(layer_x), function (item, value) { - mapTypeIds.push(value); - }); - + mapTypeIds.push(value); + + }); + $('#my_location').click(function () { if ($('#my_location').is(':checked')) { $('#autocomplete').val($('#user_location').val()); @@ -29,6 +31,7 @@ define(function (require) { $(document).ready(function () { // Initialize map vars + infowindow = new google.maps.InfoWindow(); var myLatlng = new google.maps.LatLng(map_settings['d_location_lat'],map_settings['d_location_lon']); var mapOptions = { @@ -50,13 +53,17 @@ define(function (require) { tileSize: new google.maps.Size(256, 256), name: "OpenStreetMap", maxZoom: 18 - })); - + })); + // trigger the search button for making the initial search setTimeout(function() { $("#nearby_btn").trigger('click'); + console.log(markers); + },10); - + + + return false; }); @@ -68,22 +75,22 @@ define(function (require) { } markers = []; markerBounds = new google.maps.LatLngBounds(); - + if (map_settings['cluster']) { mc.clearMarkers(); - } + } } - + // reset search area, in case it exists circle.setMap(null); - + var btn_text = $(this).val(); $(this).prop('value', 'Searching...'); $(this).css("opacity", 0.7); - + // Spiderfier feature var oms = new OverlappingMarkerSpiderfier(map,{markersWontMove: true, markersWontHide: true, keepSpiderfied: true}); - + var s_location = $('#autocomplete').val(); var s_radius = $('#s_radius').val(); var s_keyword = $('#s_keyword').val(); @@ -109,7 +116,7 @@ define(function (require) { initSearchBtn(btn_text); return false; } else { - + elgg.action(s_action, { data: { s_location: s_location, @@ -117,31 +124,27 @@ define(function (require) { s_keyword: s_keyword, showradius: showradius, initial_load: initial_load, - noofusers: noofusers, - s_change_title: s_change_title, + noofusers: noofusers, + s_change_title: s_change_title, group_guid: group_guid }, success: function (result) { if (result.error) { elgg.register_error(result.msg); } else { - if (result.change_title) { - $('.elgg-heading-main').html(result.title); - } + $('#map_location').html(result.location); $('#map_radius').html(result.radius); - + if (s_location) { $('#s_radius').val(result.s_radius); } - if (change_title != 0) { - $('.elgg-heading-main').html(result.title); - } - + + if (initial_load == 'location') { $('#my_location').prop('checked', true); } - + if (s_location && result.s_location_lat && result.s_location_lng) { //console.log('aa'+s_location+' - '+result.s_location); var myLatlng = new google.maps.LatLng(result.s_location_lat,result.s_location_lng); @@ -149,17 +152,17 @@ define(function (require) { map: map, position: myLatlng, icon: elgg.normalize_url('/mod/amap_maps_api/graphics/flag.png') - }); - map.setCenter(marker.getPosition()); - + }); + map.setCenter(marker.getPosition()); + google.maps.event.addListener(marker, 'click', function() { infowindow.setContent('Search address: '+s_location+'
Search radius: '+result.s_radius+' '+map_settings['unitmeas']); infowindow.open(map, this); - }); + }); markerBounds.extend(myLatlng); oms.addMarker(marker); // Spiderfier feature - markers.push(marker); + markers.push(marker); //console.log('aa'+showradius+' - '+result.s_radius); if (showradius && result.s_radius_no > 0) { circle = new google.maps.Circle({ @@ -170,38 +173,42 @@ define(function (require) { }); // Bind circle and marker circle.bindTo('center', marker, 'position'); - map.fitBounds(circle.getBounds()); + map.fitBounds(circle.getBounds()); } } - + var result_x = result.map_objects; $.each($.parseJSON(result_x), function (item, value) { - + var myLatlng = new google.maps.LatLng(value.lat,value.lng); var marker = new google.maps.Marker({ map: map, position: myLatlng, title: value.title, icon: value.map_icon, + type: value.type, id: 'marker_'+value.guid - }); + }); + // console.log(value); google.maps.event.addListener(marker, 'click', function() { infowindow.setContent('
'+value.info_window+'
'); infowindow.open(map, this); - }); - + }); + oms.addMarker(marker); // Spiderfier feature markers.push(marker); + console.log(markers); if (!showradius) { markerBounds.extend(myLatlng); - map.fitBounds(markerBounds); - } - - }); - - if (map_settings['cluster']) { + map.fitBounds(markerBounds); + } + + }); + // If in Global Map + + if ((document.getElementById("map_indextable") == null) && (map_settings['cluster'])) { mcOptions = { styles: [ { @@ -231,14 +238,14 @@ define(function (require) { } ], maxZoom: map_settings['cluster_zoom'] - }; + }; //init clusterer with your options mc = new MarkerClusterer(map, markers, mcOptions); } - + if (result.sidebar) { $('#map_side_entities').html(result.sidebar); - + $('.map_entity_block').click(function() { var tmp_attr = $(this).find('a.entity_m'); var object_id = tmp_attr.attr('id'); @@ -248,9 +255,9 @@ define(function (require) { google.maps.event.trigger(markers[i], 'click'); break; } - } + } }); - + $('.map_entity_block a.entity_m').click(function() { var object_id = $(this).attr('id'); for (var i = 0; i < markers.length; i++) { @@ -259,28 +266,75 @@ define(function (require) { google.maps.event.trigger(markers[i], 'click'); break; } - } - }); - } + } + }); + } + + // If in Global Map + if(document.getElementById("map_indextable") !== null) { + $('#chbx_user').click(function() { + if ($(this).is(':checked')) { + var state = true; + } else { + var state = false; + } + for (var i = 0; i < markers.length; i++) { + if (markers[i].type === "user") { + markers[i].setVisible(state); + break; + } + } + }); + + $('#chbx_group').click(function() { + if ($(this).is(':checked')) { + var state = true; + } else { + var state = false; + } + for (var i = 0; i < markers.length; i++) { + if (markers[i].type === "group") { + markers[i].setVisible(state); + break; + } + } + }); + + $('#chbx_pages').click(function() { + if ($(this).is(':checked')) { + var state = true; + } else { + var state = false; + } + for (var i = 0; i < markers.length; i++) { + if (markers[i].type === "objectpage_top") { + markers[i].setVisible(state); + break; + } + } + }); + } + + } }, complete: function () { // bring search button to normal initSearchBtn(btn_text); - + // set empty the initial input so it will not be used by search form $('#initial_load').val(''); } - }); + }); } return false; }); - + }); function initSearchBtn(btn_text) { $("#nearby_btn").prop('value', btn_text); $("#nearby_btn").css("opacity", 1); -} \ No newline at end of file +} diff --git a/views/default/amap_maps_api/location_map.js b/views/default/amap_maps_api/location_map.js index f02ab31..47bc74a 100644 --- a/views/default/amap_maps_api/location_map.js +++ b/views/default/amap_maps_api/location_map.js @@ -2,20 +2,19 @@ define(function (require) { var elgg = require('elgg'); var $ = require('jquery'); require('amap_ma_googleapis_js') - + $( document ).ready(function() { - var entity_title = $('#entity_title').text(); var entity_lat = $('#entity_lat').text(); var entity_lon = $('#entity_lon').text(); var zoom = parseInt($('#map_zoom').text()); var marker = $('#entity_marker').text(); - var gm = google.maps; - + var gm = google.maps; + // ensure that zoom is integer if (isNaN(zoom)) zoom = 12; - + infowindow = new google.maps.InfoWindow(); var myLatlng = new google.maps.LatLng(entity_lat,entity_lon); var mapOptions = { @@ -23,23 +22,21 @@ define(function (require) { center: myLatlng, mapTypeId: gm.MapTypeId.ROADMAP } - + var map = new gm.Map(document.getElementById("map"), mapOptions); var marker = new google.maps.Marker({ map: map, position: myLatlng, title: entity_title, icon: marker, - }); + }); google.maps.event.addListener(marker, "click", function() { infowindow.setContent(entity_title); infowindow.open(map, this); - }); - map.setCenter(marker.getPosition()); - - return true; - }); - -}); + }); + map.setCenter(marker.getPosition()); + return true; + }); +}); diff --git a/views/default/amap_maps_api/map.php b/views/default/amap_maps_api/map.php index c619609..6d746a4 100644 --- a/views/default/amap_maps_api/map.php +++ b/views/default/amap_maps_api/map.php @@ -1,8 +1,5 @@