Saltar navegación

[Resuelto] Customizing the Map Cluster Icons

This support ticket is created hace 1 mes, 1 semana. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Este tema contiene 0 respuestas, tiene 1 mensaje.

Última actualización por Minesh hace 1 mes.

Asistido por: Minesh.

Autor
Mensajes
#2793606

On the following documentation page:
https://toolset.com/documentation/programmer-reference/maps/customizing-cluster-markers-with-javascript-functions/

I see where I can customize the map marker images for cluster points. I've done that without any issues by providing custom PNGs in the code. But what I cannot figure out how to do is modify the breakpoints for how many map markers are represented under each cluster image.

According to this page, by default, clusters are displayed as colored circles with size depending on the number of markers they contain:

* a blue circle indicates less than 10 markers,
* a yellow circle indicates 10 to 99 markers,
* a red circle indicates 100 to 999 markers,
* a pink circle indicates 1000 to 9999 markers,
* a violet circle indicates 10000 markers or more.

I need to change the breakpoints to:
* a small circle for less than 50 markers in the cluster
* a second image for 50-99 markers in the cluster
* the third image for 100+ markers in the cluster

I assume I need to edit the code below, but I don't know how to edit it. Can you help me?

You can view the map at enlace oculto

jQuery( document ).ready( function() {
var options = {
calculator: function( markers, numStyles ) {
var index = 0, count = markers.length, dv = count, result = {};
while (dv > 0) {
dv = parseInt(dv - 5, 10);
index++;
}
index = Math.min(index, numStyles);
result = {
text: count,
index: index
};
return result;
}
};
WPViews.view_addon_maps.set_cluster_options( options, 'map-1' );
});

#2793674

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please send me amdin access details and let me review your setup and check what would be the possible solution.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2793772

The map is visible at:
enlace oculto

The active view is "Well Map" (ID: 44):
enlace oculto

#2793831

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Can you please check now: enlace oculto

I've adjusted the custom JS code as given under:

jQuery( document ).ready( function() {
  var options = {
    styles: [
      {
        'url': '<em><u>enlace oculto</u></em>',
        'height': '35',
        'width': '35',
        'textColor': '#eee'
      },
      {
        'url': '<em><u>enlace oculto</u></em>',
        'height': '45',
        'width': '45',
        'textColor': '#eee'
      },
      {
        'url': '<em><u>enlace oculto</u></em>',
        'height': '55',
        'width': '55',
        'textColor': '#eee'
      }
    ],
    calculator: function( markers, numStyles ) {
      var index = 0, count = markers.length, dv = count, result = {};
      
      while (dv > 0) {
        dv = parseInt(dv - 50, 10);
        index++;
      }
     
      index = Math.min(index, numStyles);
      result = {
        text: count,
        index: index
      };
      return result;
    }
  };
  WPViews.view_addon_maps.set_cluster_options( options, 'well-map-1' );
});

Can you please confirm it works as expected.