Action from popup - select points within a selected polygon

with this sql query i can get all the points within a polygon (gid = 1652):

SELECT  
	polygon.gid,
	points.*
	FROM polygon
	LEFT JOIN points
	ON st_contains(polygon.the_geom, points.the_geom)
	WHERE polygon.gid = 1652

i’ am trying to adapt the action_name = ‘closest_fire_station’ like this:

    datasource:= format('
		WITH tmp_polygon AS (
            SELECT the_geom FROM polygon WHERE gid = ''%1$s''				
		)
		SELECT
			points.*,
			LEFT JOIN points
			ON st_contains(polygon.the_geom, points.the_geom),
			''mensagem'' AS message
		FROM
			tmp_polygon polygon
    ',

but without success

can someone help me please?
thanks in advance

	        SELECT
            	%1$s AS gid,
				''message'' AS message,
            	polygon.the_geom AS the_geom
            FROM polygon
            WHERE gid = %1$s

What do you mean with your latest message ? Can you give some more context ?

but without success

What does it give you ? Does your query returns something ? Is-there an error message ?

Just a note about the new OpenLayers style which must be used : Fixing action style for new OpenLayers by rldhont · Pull Request #262 · 3liz/lizmap-documentation · GitHub

hi @etrimaille

i can solve my problem with the code above inside lizmap_get_data function

Just a note about the new OpenLayers style which must be used : Fixing action style for new OpenLayers

it’s not enough, the action icon doesn´t appear on toolbar popup

i can confirm, the action module is ok on 3.8!
thanks

1 Like