Skip to content

import marker color from kml or geojson #494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simonLouvet opened this issue May 24, 2017 · 7 comments
Closed

import marker color from kml or geojson #494

simonLouvet opened this issue May 24, 2017 · 7 comments

Comments

@simonLouvet
Copy link

Hello,

I try to specify color of marker during an import but that don't seem effectiv.

<Document>
        <Placemark>
            <Point>
                <coordinates>1.8457031250000002,47.45780853075031</coordinates>
            </Point>
            <styleUrl>#Style00</styleUrl>
        </Placemark>
        <Style id="Style00">
            <LineStyle>
                <color>ff6e6e6e</color>
            </LineStyle>
            <IconStyle>
                <color>ff6e6e6e</color>
            </IconStyle>
        </Style>
    </Document>

I ever try other color format (kml, Umap Color..).

@M-Rick
Copy link

M-Rick commented Oct 6, 2018

Hi
You already can do it.
In your GeoJSON, just add a new column _umap_options and in your datas values add this { "color": "green" }
You can edit your GeoJSON file in QGIS and apply a dynamic calculation from the color column over the new _umap_options just like this concat( '{ "color": "', "my_colors",'" }' ). And then when you will import your datas in uMap, you won't have to set all the colors again, all will be ready. It works for any of the settings, such as transparency, dashes, weight, labels, icons etc.

capture d ecran 2018-10-06 a 23 54 38
capture d ecran 2018-10-06 a 23 55 13

You can even prepare all your datas directly, if you create a name and a description columns and fill them with the texts dedicated to them including the CSS style to format the rendering.
With this, you can create an uMap in just a few clicks and a few minutes.

capture d ecran 2018-10-06 a 23 56 28

capture d ecran 2018-10-06 a 23 56 50

@eiland-asbl
Copy link

I'm trying to get my head around to setting the pin-style in my csv, but whenever i try to import a _umap_options field, it dissappears, or at least, it doesn't style my pin?

@skramm
Copy link

skramm commented Oct 27, 2021

Hi, I'm here coming from https://help.openstreetmap.org/questions/82388/
The tip here from @M-Rick is a bit unclear to me. I don't know what software you are showing here (GeoJSON is a file format, AFAIK).
I tried something like this:

{ "type": "FeatureCollection",
    "features":
    	[
            { "type": "Feature",
                 "geometry":
	        	{
	        		"type": "Point", 
    			    "coordinates": [2.2908106734441,48.8421565600018]
    			},
		        "_umap_options": {"color": "green" }
	        },
        	{ "type": "Feature",
            "geometry":
	        	{
	        		"type": "Point", 
    			    "coordinates": [2.40580700033425,48.8756657433978],
		        	"_umap_options": {"color": "red" }
	        	}
        	}
    	]
}

I tried placing the color inside the "point" or inside the "Feature", none of these seems to work.
Any hint?

@skramm
Copy link

skramm commented Oct 29, 2021

Oh, sorry, didn't see you were talking about QGIS, my bad. I'll have a try.

@skramm
Copy link

skramm commented Nov 13, 2021

ok, finally got that. For others that follow the same path as me, here is a sample of something that works.
I think that the issue can be closed now.

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "name": "Collège Bidule","_umap_options": { "color": "yellow" }
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          2.332706,
          48.86614
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Ecole maternelle Truc","_umap_options": { "color": "green" }
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          2.290811,
          48.842157
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "Ecole primaire Machin", "_umap_options": {"color": "red"}
      },
      "geometry": {
        "type": "Point",
        "coordinates": [
          2.405807,
          48.875666
        ]
      }
    }
  ]
}

@simonLouvet
Copy link
Author

thanks a lot @skramm

@dawansv
Copy link

dawansv commented Sep 17, 2022

I'm trying to get my head around to setting the pin-style in my csv, but whenever i try to import a _umap_options field, it dissappears, or at least, it doesn't style my pin?

_umap_options is removed from the table view by design. The problem is not that, but the fact that in a CSV _umap_options is processed as a quoted string, not as raw JSON, so instead of { "color": "red" } it is processed as "{\"color": \"red\" }" and it ends up looking like a series of single characters options after processing.

"_umap_options": {
          "0": "{",
          "1": "\"",
          "2": "c",
          "3": "o",
          "4": "l",
          "5": "o",
          "6": "r",
          "7": "\"",
          "8": " ",
          "9": ":",
          "10": " ",
          "11": "\"",
          "12": "r",
          "13": "e",
          "14": "d",
          "15": "\"",
          "16": "}"
        }

I don't really think there is a way around it without converting your csv to GeoJSON first. Which is too bad because I was trying to use this from a remove google spreadsheet csv but indeed although I can pass the regular fields that way, no luck with passing per-record _umap_options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants