Pentaho

 View Only

 Customize NewMap MaxZoom

  • Pentaho
  • Ctools
  • Pentaho
David Martinez's profile image
David Martinez posted 03-14-2018 16:30

We need to increase the zoom level of the newmap component. the maximum zoom by default is not enough for the correct visualization of the data.

We have tried to modify this property through javascript without success.

  any ideas?


#Ctools
#Pentaho
Joana Carvalho's profile image
Joana Carvalho

Hi David, try this - this.defaultZoomLevel = 2; in the PreExec of the NewMap.

Then, you need to update the default zoom level according to what you want.

David Martinez's profile image
David Martinez

Hi Joana !!

"this.defaultZoomLevel = 2" works fine with zoomlevels between 0 and 15, the point is that we need higher ones.

There is no difference between defaultZoomLevel = 15 and defaultZoomlevel = 20.

 

 

Regards.

Joana Carvalho's profile image
Joana Carvalho

Hi David,

The tiler provider, which corresponds to images that the map is made of, is responsible for defining the zoom levels available in the map.

By default, the tiler provider used is openstreetmap and it has [0,19] zoom levels: https://wiki.openstreetmap.org/wiki/Zoom_levels

However, in the new map component, you can choose another tiler provider, that will have other zoom levels - Tilesets to display as layers property.

 

screen-shot-2018-03-20-at-11

 

Thanks,

 

Joana

David Martinez's profile image
David Martinez

hi Joana,

     Looks like it isn't a map provider limitation, but  component's limitation.

     The NewMap component limits zoom to 15, no matters what tileset you are using.

     This is why we are looking for some workarround to solve it.

     Some examples:

Center Latitude40.4170Center Longitude-3.7033Tilesets to display as layersstamen-tonerDefault zoom Level19

     The dashboard view, actualy you can see that zoom is 15, not 19,  Same settings in Stamen Map: Click-->     http://maps.stamen.com/toner/#19/40.41699/-3.70329

pastedimage_0

Center Latitude40.4170Center Longitude-3.7033Tilesets to display as layersstamen-tonerDefault zoom Level19

     The dashboard view, actualy you can see that zoom is 15, not 19,  Same settings in OpenStreetMap: Click -->   https://www.openstreetmap.org/#map=19/40.41699/-3.70329

     pastedimage_6

Thanks.

Carlos Russo's profile image
Carlos Russo

The limitation is actually in the underlying library, OpenLayers, which defines 16 zoom levels by default: OpenLayers.Map - OpenLayers 2

To work around this, you will need to define in preExecution:

this.options = {

viewport: {

   zoomLevel: {

     max: 19 // The default of this setting is Infinity

   }

  }

};

David Martinez's profile image
David Martinez

Hi Carlos,

This work arround looks great, but zoom istill not working beyond 15.

If we put a breackpoint in postExecution, we can see value changing from Infinity to 19, but zoom is still limited in the map view.

We were messing arround with similar js codes without success, also looking the mapEngine objet generated by the dashboard and trying to modify it.

                                     ex: Inspired in Github's one  Pentaho NewMapComponent · GitHub  (line 340)

maybe we should also change some other properties?

Carlos Russo's profile image
Carlos Russo

If the work around I suggested still doesn't work, then I'm afraid we'll need to fix the component to instantiate the map object with the correct settings. Can you file a bug at https://jira.pentaho.com under the project CDE?

There's an ugly way to do this: You can modify the prototype of the MapEngineOpenLayers class by requiring it as a dashboard resource and overwriting the renderMap method,  augmenting the mapOptions object:

cde/MapEngineOpenLayers.js at master · webdetails/cde · GitHub

with the property "numZoomLevels" set to this.options.viewport.zoomLevel.max or some finite number (e.g. 19)

David Martinez's profile image
David Martinez

Hi Carlos..

Bug filed:  [CDE-955] NewMapComponent - Can't set zoomlevels higher than 15 - Pentaho Platform Tracking

Some feedback :

  • Setting Vieport zoomLevel in preExecution (min & max) works great if zoomLevel values are between 0 and 15. If  value is greater than 15, is ignored and level 15 was shown.
  • The "Ugly way" modifing numZoomLevels=19 causes an erratic behavior. The center of the map goes from being in Madrid to being in the center of the Atlantic, you can not move through the map, etc ... Looks like coords conversion can't be correctly done for higher zoomlevels.

Thanks,

David.