Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I've enabled "distinct" values in the query settings, however I am still getting duplicate markers on my OL views map.
Any ideas?
Comments
Comment #1
wemmies CreditAttribution: wemmies commentedPlease share some more info, what are your filter settings? What contextual filters are you using?
Comment #2
ekes CreditAttribution: ekes commentedAn export of the view might help.
Comment #3
tlinteau CreditAttribution: tlinteau commentedI'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.
Comment #4
tlinteau CreditAttribution: tlinteau commentedHere'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;
Comment #5
tlinteau CreditAttribution: tlinteau commentedOk, 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.
Comment #6
tlinteau CreditAttribution: tlinteau commentedComment #7
rudiedirkx CreditAttribution: rudiedirkx commentedThis 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()
inopenlayers_render_map()
(which happens twice), I see a slight difference in trace: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 classopenlayers_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).Comment #8
rudiedirkx CreditAttribution: rudiedirkx commentedComment #9
rudiedirkx CreditAttribution: rudiedirkx commentedMy unacceptable 'fix' for completeness:
YOURMOD.module:
YOURMOD_openlayers_views_style_data.inc:
And don't forget to add
idmod_openlayers_views_style_data
to thefiles[]
inYOURMOD.info
.This should absolutely NOT be considered a patch!
Comment #10
Cellar Door CreditAttribution: Cellar Door commentedThis 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?
Comment #11
Cellar Door CreditAttribution: Cellar Door commentedLate 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?
Comment #12
rudiedirkx CreditAttribution: rudiedirkx commentedIt'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...
Comment #13
Cellar Door CreditAttribution: Cellar Door commentedPossibly 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?
Comment #14
rudiedirkx CreditAttribution: rudiedirkx commentedWithout 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?Comment #15
PolHi 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 !
Comment #16
tamarackmedia CreditAttribution: tamarackmedia commentedThanks, Cellar Door, I had the duplicates problem w/ Exposed Filters enabled and grouping by title did the trick.
Comment #17
pvaling CreditAttribution: pvaling commentedCellar Door fix with grouping is working but its break Pop Up layout (its rendered as list with blank items on second level).
Comment #18
PolHi,
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!
Comment #19
rudiedirkx CreditAttribution: rudiedirkx commentedMy 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.