# LoadLayerOptions()

**URL:** <https://mapwindow.discourse.group/t/loadlayeroptions/250>\
**Category:** MapWinGIS\
**Created:** [September 13, 2019, 10:56am UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250 "2019-09-13T10:56:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![cxdeus](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@cxdeus](https://mapwindow.discourse.group/u/cxdeus)\
**Post date:** [September 13, 2019, 10:56am UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/1 "2019-09-13T10:56:38Z")

</div>

Hi everyone,

I use MapWinGis and it is really very useful.I use PostgreSQL and i move my shape files to PostgreSql via PostGis 2.0 ShapeFile.Layers are shown very quickly with AddLayerFromDatabase method.BUt i have one question.I have created mw\_styles table.I inserted layer, style name etc. data into it.How can i load style from PostgreSQL database? As far as i know LoadLayerOptions only work with a file.I tried LoadLayerOptions with a shape file it worked correctly.But i want to get styles from PostgreSQL database?How can i do?

Thanks for you help

---

<div class="post-metadata">

**Author:** ![HenrikKartin](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@HenrikKartin](https://mapwindow.discourse.group/u/HenrikKartin)\
**Post date:** [September 13, 2019, 1:19pm UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/2 "2019-09-13T13:19:39Z")

</div>

I can’t give you a specific solution to your problem.  
But I may be able to push you in the right direction.

When you add styles to a layer in QGIS and save it to PostgreSQL it automatically creates a table in the public schema called “layer\_styles”.  
It contains a reference to your table and the spatial data column and the style definition in xml format.

My guess is that you somehow can create this table yourself!?

Please let me know if you want an example.

And please let me know if you find a solution.  
I will need to do something similar in the near future.

Regards,  
Henrik

---

<div class="post-metadata">

**Author:** ![cxdeus](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@cxdeus](https://mapwindow.discourse.group/u/cxdeus)\
**Post date:** [September 13, 2019, 1:25pm UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/3 "2019-09-13T13:25:26Z")

</div>

Hi Henrik,

Do you mean that layer\_styles table in postgresql automatically loads style for layers in MapWinGis?  
I am going to try and will inform you

But my question is how the load style from mw\_styles table in PostgreSql?Which method should i use?LoadLayerOption method doesnt seem to be success.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![HenrikKartin](https://avatars.discourse-cdn.com/v4/letter/h/c89c15/32.png) [@HenrikKartin](https://mapwindow.discourse.group/u/HenrikKartin)\
**Post date:** [September 13, 2019, 2:49pm UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/4 "2019-09-13T14:49:31Z")

</div>

No, QGIS is a separat GIS open source system. I just thought that the layer\_styles table was a PostgresSQL object. But it’s not.

On the MapWinGIS OgrLayer Class you have a property called SupportsStyles: “Checks whether the layers supports saving of styles to the datasource.”.

I’ve just tried it with my own PostgreSQL layer - and it does not support Styles.  
So it looks like we have to do code that on our own.

So the question is if it’s possible to replicate the structure of the mw\_styles file and save it to PostgreSQL?

---

<div class="post-metadata">

**Author:** ![cxdeus](https://avatars.discourse-cdn.com/v4/letter/c/d6d6ee/32.png) [@cxdeus](https://mapwindow.discourse.group/u/cxdeus)\
**Post date:** [September 13, 2019, 3:11pm UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/5 "2019-09-13T15:11:12Z")

</div>

I checked OrgLayer Class SupportsStyles returns false.  
My question is LoadLayerOptions method load styles from ShapeFile in my disk.I want to load styles from PostgreSql database.How can i do?I have all tables and spatial database

Thanks

---

<div class="post-metadata">

**Author:** ![Mathijs.Dumon](https://avatars.discourse-cdn.com/v4/letter/m/9de053/32.png) [@Mathijs.Dumon](https://mapwindow.discourse.group/u/Mathijs.Dumon)\
**Post date:** [November 4, 2019, 2:50pm UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/6 "2019-11-04T14:50:07Z")

</div>

For a database layer I think you can just call LoadLayerOptions () with the layer handle and empty strings for the optionsname and description

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 3:08pm UTC](https://mapwindow.discourse.group/t/loadlayeroptions/250/7 "2022-01-05T15:08:54Z")

</div>


