Skip to content
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

Add icon-image in variable style props #281

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Conversation

Bo-Duke
Copy link
Member

@Bo-Duke Bo-Duke commented Jul 7, 2023

I don't have the python skills to test that but this is what it should do :

Currently, when the admin sends a layer config (to api/geolayer/<id>) with this (only keps the minimal stuff for the example) :

{
	"main_style": {
		"map_style_type": "icon",
		"style": {
			"icon_image": {
				"analysis": "categorized",
				"categories": [
					{
						"name": "deuxième",
						"value": "icon-2"
					},
					{
						"name": "premier",
						"value": "icon-1"
					},
					{
						"name": "quatrième",
						"value": "icon-2"
					},
					{
						"name": "troisième",
						"value": "icon-1"
					}
				],
				"field": "name",
				"type": "variable",
			},
		},
		"type": "wizard",
	}
}

the map_style object (send back to the admin in main_style.map_style and the one sent to the front) returned is this :

{
	"map_style": {
		"type": "symbol",
		"minzoom": 0,
		"maxzoom": 24,
	}
}

When we should have the icon_image style generated like this :

{
	"layout": {
		"icon-image": [
			"match",
			[
				"get",
				"name"
			],
			"deuxième",
			"icon-2",
			"premier",
			"icon-1",
			"quatrième",
			"icon-2",
			"troisième",
			"icon-1",
			"icon-2"
		]
	}
}

If I understood everything, the icon-image prop is not added to map_style because field_2_variation_type returns nothing, so no condition of the ifs is true

variation_type = field_2_variation_type(map_field)

When we want it to go there ->

elif analysis == "categorized":

Hopefully I didn't miss anything and this should work (not sure about legend gen tho but that's less important)

@submarcos submarcos merged commit 166d42d into master Jul 11, 2023
@submarcos submarcos deleted the categorize-icon-image branch July 11, 2023 07:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants