Saving Map Preferences from a Combobox on Map Toolbar

obby6 years ago

I'm adding the option to change the map type on the map toolbar. This is as a combobox as shown below.
I'm not well versed with JS and frontend development but i'm looking for pointers on how I can affect the changed by saving the new selected maptype as the user map.

In app/view/map/Map.js, I have added the component and a listener.

{
     xtype: 'clearableComboBox',
     name: 'map',
     fieldLabel: '',
     store: 'MapTypes',
     displayField: 'name',
     valueField: 'key',
     listeners: {
            select: 'onItemSelected'
      }
}

in app/view/map/MapController.js, I have added the function that is called when item is selected above.

onItemSelected: function (combo, record) {
        
       // to do??
        window.location.reload();
    }

How do I get hold of the current user in order to save this new maptype as their selected map?

Also, is there a way I can reload only the map panel instead of the whole page?

Anton Tananaev6 years ago

You can use Traccar.app.getUser(). It's not possible to reload the map. I believe that you just need to change layers.

obby6 years ago

If I change the layer I have to refresh the page to get the changes (even from the account settings). So I will have to reload the whole page as I have done above?

Also, if i get the user, how do I save the new information? I tried checking the code in UserController.js but it was complicated to me. do i need to sync the store after setting the new map to user? Kindly elaborate

Anton Tananaev6 years ago

We provide paid support if you need help with customisation.

obby6 years ago

Okay. How do I go about it and could you provide the rates?

Anton Tananaev6 years ago

Hourly rate is here:

https://www.traccar.org/product/professional-services/

Please send an email to support address if you want a quote for specific work.