I've enabled "distinct" values in the query settings, however I am still getting duplicate markers on my OL views map.

Any ideas?

Comments

Please share some more info, what are your filter settings? What contextual filters are you using?

Status:Active» Postponed (maintainer needs more info)

An export of the view might help.

I'm having similar issues. The problem seems to be when creating the OpenLayers Data Overlay view. I tried creating a Custom Field containing things like address, fax, phone, etc and selecting that custom field as the description field for tooltips. The marker coordinates are right but the custom field is duplicated throughout all of the tooltips. If I didn't select the custom field but selected only the address (single field) then it displayed properly. VERY strange.

Here's the view in question:

$view = new view();
$view->name = 'facility_map';
$view->description = '';
$view->tag = 'default';
$view->base_table = 'node';
$view->human_name = 'Facility Map';
$view->core = 7;
$view->api_version = '3.0';
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */

/* Display: Master */
$handler = $view->new_display('default', 'Master', 'default');
$handler->display->display_options['use_more_always'] = FALSE;
$handler->display->display_options['access']['type'] = 'perm';
$handler->display->display_options['cache']['type'] = 'none';
$handler->display->display_options['query']['type'] = 'views_query';
$handler->display->display_options['exposed_form']['type'] = 'basic';
$handler->display->display_options['pager']['type'] = 'full';
$handler->display->display_options['style_plugin'] = 'openlayers_data';
$handler->display->display_options['style_options']['data_source'] = array(
'value' => 'wkt',
'other_lat' => 'title',
'other_lon' => 'title',
'wkt' => 'field_coordinated',
'other_top' => 'title',
'other_right' => 'title',
'other_bottom' => 'title',
'other_left' => 'title',
'name_field' => 'title',
'description_field' => 'nothing',
);
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['hide_empty'] = TRUE;
/* Field: Content: Title */
$handler->display->display_options['fields']['title']['id'] = 'title';
$handler->display->display_options['fields']['title']['table'] = 'node';
$handler->display->display_options['fields']['title']['field'] = 'title';
$handler->display->display_options['fields']['title']['label'] = '';
$handler->display->display_options['fields']['title']['exclude'] = TRUE;
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE;
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE;
$handler->display->display_options['fields']['title']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['title']['element_wrapper_type'] = 'strong';
$handler->display->display_options['fields']['title']['link_to_node'] = FALSE;
/* Field: Content: Address */
$handler->display->display_options['fields']['field_address']['id'] = 'field_address';
$handler->display->display_options['fields']['field_address']['table'] = 'field_data_field_address';
$handler->display->display_options['fields']['field_address']['field'] = 'field_address';
$handler->display->display_options['fields']['field_address']['label'] = '';
$handler->display->display_options['fields']['field_address']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_address']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_address']['hide_empty'] = TRUE;
$handler->display->display_options['fields']['field_address']['click_sort_column'] = 'country';
$handler->display->display_options['fields']['field_address']['settings'] = array(
'use_widget_handlers' => 1,
'format_handlers' => array(
'address' => 'address',
),
);
/* Field: Content: Fax */
$handler->display->display_options['fields']['field_fax']['id'] = 'field_fax';
$handler->display->display_options['fields']['field_fax']['table'] = 'field_data_field_fax';
$handler->display->display_options['fields']['field_fax']['field'] = 'field_fax';
$handler->display->display_options['fields']['field_fax']['label'] = '';
$handler->display->display_options['fields']['field_fax']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_fax']['element_label_colon'] = FALSE;
/* Field: Content: Phone */
$handler->display->display_options['fields']['field_phone']['id'] = 'field_phone';
$handler->display->display_options['fields']['field_phone']['table'] = 'field_data_field_phone';
$handler->display->display_options['fields']['field_phone']['field'] = 'field_phone';
$handler->display->display_options['fields']['field_phone']['label'] = '';
$handler->display->display_options['fields']['field_phone']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_phone']['element_label_colon'] = FALSE;
/* Field: Content: Website */
$handler->display->display_options['fields']['field_website']['id'] = 'field_website';
$handler->display->display_options['fields']['field_website']['table'] = 'field_data_field_website';
$handler->display->display_options['fields']['field_website']['field'] = 'field_website';
$handler->display->display_options['fields']['field_website']['label'] = '';
$handler->display->display_options['fields']['field_website']['exclude'] = TRUE;
$handler->display->display_options['fields']['field_website']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_website']['click_sort_column'] = 'url';
/* Field: Content: Coordinates */
$handler->display->display_options['fields']['field_coordinated']['id'] = 'field_coordinated';
$handler->display->display_options['fields']['field_coordinated']['table'] = 'field_data_field_coordinated';
$handler->display->display_options['fields']['field_coordinated']['field'] = 'field_coordinated';
$handler->display->display_options['fields']['field_coordinated']['label'] = '';
$handler->display->display_options['fields']['field_coordinated']['element_label_colon'] = FALSE;
$handler->display->display_options['fields']['field_coordinated']['click_sort_column'] = 'wkt';
$handler->display->display_options['fields']['field_coordinated']['settings'] = array(
'data' => 'full',
);
/* Field: Content: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';
$handler->display->display_options['fields']['nid']['field'] = 'nid';
$handler->display->display_options['fields']['nid']['label'] = '';
$handler->display->display_options['fields']['nid']['element_label_colon'] = FALSE;
/* Field: Global: Custom text */
$handler->display->display_options['fields']['nothing']['id'] = 'nothing';
$handler->display->display_options['fields']['nothing']['table'] = 'views';
$handler->display->display_options['fields']['nothing']['field'] = 'nothing';
$handler->display->display_options['fields']['nothing']['label'] = '';
$handler->display->display_options['fields']['nothing']['exclude'] = TRUE;
$handler->display->display_options['fields']['nothing']['alter']['text'] = '[field_address]
Phone: [field_phone]
Fax: [field_fax]
[field_website]';
$handler->display->display_options['fields']['nothing']['element_label_colon'] = FALSE;
/* Filter criterion: Content: Published */
$handler->display->display_options['filters']['status']['id'] = 'status';
$handler->display->display_options['filters']['status']['table'] = 'node';
$handler->display->display_options['filters']['status']['field'] = 'status';
$handler->display->display_options['filters']['status']['value'] = 1;
$handler->display->display_options['filters']['status']['group'] = 1;
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE;
/* Filter criterion: Content: Type */
$handler->display->display_options['filters']['type']['id'] = 'type';
$handler->display->display_options['filters']['type']['table'] = 'node';
$handler->display->display_options['filters']['type']['field'] = 'type';
$handler->display->display_options['filters']['type']['value'] = array(
'facility_for_map_' => 'facility_for_map_',
);

/* Display: OpenLayers Data Overlay */
$handler = $view->new_display('openlayers', 'OpenLayers Data Overlay', 'openlayers_1');
$handler->display->display_options['defaults']['hide_admin_links'] = FALSE;
$handler->display->display_options['pager']['type'] = 'none';
$handler->display->display_options['pager']['options']['offset'] = '0';
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['row_plugin'] = 'fields';
$handler->display->display_options['row_options']['hide_empty'] = TRUE;

Ok, struggle long enough and you end up figuring it out yourself.

Tip: If you want to create a custom field (to combine fields for display as the description), don't exclude them from display or you'll get dupes and scratch your head for days.

Status:Postponed (maintainer needs more info)» Closed (works as designed)

Status:Active» Needs work

This is definitely not as designed. All markers are exactly double. openlayers_views_style_data::map_features is executed twice with all Views results and ALL results are added to the same map (so every marker shows twice on the EXACT same position). If I print $this->view->current_display in that function, it prints the same (correct) display twice. Why twice? There's only 1 map display!

What does happen twice:

* The list: one in the map and one in the list below.
* The query: a count and a fetch (so actually there's 4 queries).

I think it has something to do with the map being an attachment. If I do a debug_backtrace() in openlayers_render_map() (which happens twice), I see a slight difference in trace:

    1. view->execute_display
    2. view->execute
    3. view->build
    4. view->attach_displays
    5. view->attach_to
    6. view->execute_display
    7. display->execute
    8. view->render
    9. display->render
    10. theme
    11. template_preprocess_views_view
    12. openlayers_views_style_map->render
    13. openlayers_render_map etc
    1. view->execute_display
    2. view->execute
    3. view->build
    4. view->attach_displays
    5. view->attach_to
    6. view->execute_display
    7. display->execute
    8. view->render
    9. view->execute
    10. openlayers_views_style_map->query
    11. openlayers_render_map etc

I've no idea how or why... The last part is different, which is very weird. I think the one triggers another of itself... It's definitely not a distinct or group by problem.

Reproducing should be easy:

* create a view page (e.g. HTML list) with items
* create a data overlay (OpenLayers Data Overlay)
* create an attachment (OpenLayers Map) and attach it to (Before) the view page
* put a debug statement in openlayers_render_map()

One way to 'fix' it, is alter views_plugins to override class openlayers_views_style_data::map_features() and set it to an empty array the second time. Hardly a fix, but it does the double marker problem (and cuts JS settings in half).

Version:7.x-2.0-beta1» 7.x-2.0-beta5
Status:Closed (works as designed)» Active

Status:Needs work» Active

My unacceptable 'fix' for completeness:

YOURMOD.module:

<?php
function YOURMOD_views_api() {
  return array(
'api' => 3);
}
function
YOURMOD_views_plugins_alter(&$data) {
 
$data['style']['openlayers_data']['handler'] = 'YOURMOD_openlayers_views_style_data';
}
?>

YOURMOD_openlayers_views_style_data.inc:

<?php
class YOURMOD_openlayers_views_style_data extends openlayers_views_style_data {
  function
map_features($sets = array()) {
   
$features = parent::map_features($sets);
    if (
$this->view->name == 'YOURVIEW') {
      static
$first_time = TRUE;
     
// Remove all features all next times, because OL doubles them to the same map for some reason.
     
if (!$first_time) {
       
$features = array();
      }
     
$first_time = FALSE;
    }
   
// Keep only the 2 attributes actually used: name & description.
   
$keys = array_flip(array('name', 'description'));
    foreach (
$features as &$feature) {
     
$feature['attributes'] = array_intersect_key($feature['attributes'], $keys);
      unset(
$feature);
    }
    return
$features;
  }
}
?>

And don't forget to add idmod_openlayers_views_style_data to the files[] in YOURMOD.info.

This should absolutely NOT be considered a patch!

This is odd but I'm getting duplicated data as well but only when exposing a filter on the view. The filter is setup to be the same on the map page and the data overlay - no overrides etc. but anytime I enable the filter **bam** duplicated data.

Think it's related?

Late night fuzzies I'm not sure but was trying all sorts of options and found that if I grouped by title my duplication went away. Maybe you can try the same?

It's not the query that's wrong. As you can see in my previous comment, the map is loaded twice. All markers are loaded twice. The display plugin is loaded and executed twice. If you' have debugged openlayers_render_map() you'd have seen only 1. I have 2, because the whole thing is executed twice.

I do have 3 exposed filters though...

Possibly the exposed filter is causing a duplication in rendering? Not sure our two issues are related but it may be worth a look into. If you keep everything the same and remove the exposed filters do you get duplication?

Without any exposed filters, I get the same result: the whole map thing is loaded/executed twice.

Maybe yours just looks like it's executing only once? Could you put a debug statement in openlayers_render_map()? Mine prints twice. Yours?

Hi all,

I'm following the thread, I just don't have a lot of time to work on OL right now.
I'm preparing the DC, plus some other personnal stuff makes me away for a couple of days now.
As soon as we have found a solution for this, I'll try to commit it asap !

Thanks for your implication all !

Thanks, Cellar Door, I had the duplicates problem w/ Exposed Filters enabled and grouping by title did the trick.

Version:7.x-2.0-beta5» 7.x-2.0-beta9
Issue summary:View changes

Cellar Door fix with grouping is working but its break Pop Up layout (its rendered as list with blank items on second level).

Hi,

I've worked on popup rendering these last days and I'm ready to give it a bit more time if you explain exactly the steps to reproduce the problem.

Thanks!

My problem was duplicate markers. Any view, any set up. Look at (inspect) the source. Count the markers. Is that the right amount? Put a debug statement in openlayers_render_map(). It prints twice.