[Mapbender-users] Digitizer : different color for the objects

Gérald Salin gerald.salin at gmail.com
Mon Jun 25 22:24:39 PDT 2018


I achieved my goal slighlty differently, but you gave me the solution.
As I also want to display the type in the table to allow the search against
it on the interface.
I added a "color" column and I tried setting an event in the digitizer
config to set this color. Just for trying :

events  onBeforeInsert: $item['color'] = "#ffff00";

But after saving, this line was automatically modified as

onBeforeInsert: '$item[''color''] = "#ffff00"';


This event had no effect, maybe I've done something wrong...

So I created a trigger on insert/update in lines table, in the
postgresql database, with the following function :


--
-- Name: setColor(); Type: FUNCTION; Schema: public; Owner: mapbender-au1
--

CREATE FUNCTION public."setColor"() RETURNS trigger
    LANGUAGE plpgsql
    AS $$BEGIN
  IF NEW.type = 'REV' THEN
    NEW.color='#0000ff';
  ELSIF NEW.type = 'LiaisonIntercommunale' THEN
    NEW.color='#00ff00';
  ELSE
    NEW.color='#ff0000';
 END IF;
 RETURN NEW;
END;$$;

--

COMMENT ON FUNCTION public."setColor"() IS 'set color column according
to the type';

that works great!!!

Next step now ;)

Bye

Gérald



2018-06-24 23:26 GMT+02:00 Gérald Salin <gerald.salin at gmail.com>:

> great, will try it asap!!!
> thank you Astrid
>
>
> 2018-06-24 11:47 GMT+02:00 Astrid Emde <astrid.emde at wheregroup.com>:
>
>> Hello Gérald,
>>
>> you can do this easily as you can use die OpenLayers 2 styles in the
>> digitizer.
>>
>> See OpenLayer 2 styles documentation: http://docs.openlayers.org/lib
>> rary/feature_styling.html
>>
>> You should add a new column for the color in your table, that you fill
>> depending on the choice of the user.
>>
>> f.e.
>>
>> Alter table poi add column color varchar;
>>
>> As Mapbender does not support combo you could choose a selectbox  for the
>> different types.
>>
>> Add the selectbox to your digitizer configuration:
>>
>> f.e.
>>
>>             -
>>               type: select
>>               title: Type
>>               name: color
>>               options:
>>                 '#ff00ff': Type-A
>>                 '#00ffff': Type-B
>>                 '#ffff00': Type-C
>>                 '#00ff00': Type-D
>>
>>
>> Styles could look like this - with ${color} you refer to the new column
>> with the color values
>>
>>   styles:
>>     default:
>>       strokeWidth: 2
>>       strokeColor: '#0e6a9e'
>>       fillColor: ${color}
>>       fillOpacity: 1
>>       fillWidth: 2
>>       pointRadius: 10
>>     select:
>>       strokeWidth: 3
>>       strokeColor: ${color}
>>       fillOpacity: 0.7
>>       pointRadius: 10
>>
>> Happy cycling!
>>
>> Astrid
>>
>> Am 2018-06-23 17:00, schrieb Gérald Salin:
>>
>>> Hi mapbender users,
>>>  we (a french cyclist association, bicycle as a way of transport)
>>> would like to use mapbender to allow cyclists to draw lines on a map
>>> of the most important cyclable axes which they think is missing. We
>>> are still evaluating mapbender. I already posted a message few weeks
>>> ago and are still evaluate mapbender.
>>> We would like to associate a type (combo with 3 items in the form) to
>>> the lines added by the cyclists, and visually differentiate them on
>>> the map.
>>>
>>> do you know if there is a way to associate a color to each type so
>>> that the lines appear differently on the map?
>>>
>>> Thank you for your help
>>>
>>> Gérald--
>>>
>>> VelObs : remontez vos problèmes lors des déplacements à vélo sur
>>> le web [1] ou sur android [2] (une appli 2P2R [3])
>>> Pedibus labégeois [4]
>>> Soutenez ICEA [5], Inititiative Citoyenne pour une Energie
>>> Alternative, prenez ou offrez des parts sociales pour devenir
>>> co-propriétaire de panneaux photovoltaïques
>>> Consommez de l'énergie éléctrique verte renouvelable avec ENERCOOP
>>> [6]
>>>
>>>
>>>
>>> Links:
>>> ------
>>> [1] https://velobs.2p2r.org/
>>> [2]
>>> https://play.google.com/store/apps/details?id=org.deuxpiedsd
>>> euxroues.velobs.tlse&hl=fr
>>> [3] https://2p2r.org/
>>> [4] https://emilepattesblog.wordpress.com/
>>> [5] http://icea-enr.fr/
>>> [6] http://www.enercoop.fr/
>>> _______________________________________________
>>> Mapbender_users mailing list
>>> Mapbender_users at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/mapbender_users
>>>
>>
>> --
>> Mit freundlichen Grüßen
>>
>> Astrid Emde
>> Senior GIS-Consultant
>>
>> -----------------------------------
>> Aufwind durch Wissen!
>> Qualifizierte Open-Source-Schulungen
>> bei der www.foss-academy.com
>> -----------------------------------
>>
>>
>>  Astrid Emde
>>  WhereGroup GmbH & Co.KG
>>  Eifelstraße 7
>>  53119 Bonn
>>  Germany
>>
>>  Fon: +49(0)228 90 90 38 - 22
>>  Fax: +49(0)228 90 90 38 - 11
>>
>>  astrid.emde at wheregroup.com
>>  www.wheregroup.com
>>
>>  Folgen Sie der WhereGroup auf twitter: http://twitter.com/WhereGroup_com
>>
>> Amtsgericht Bonn, HRA 6788
>> -------------------------------
>> Komplementärin:
>> WhereGroup Verwaltungs GmbH
>> vertreten durch:
>> Olaf Knopp, Peter Stamm
>> -------------------------------
>> _______________________________________________
>> Mapbender_users mailing list
>> Mapbender_users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/mapbender_users
>
>
>
>
> --
> VelObs : remontez vos problèmes lors des déplacements à vélo sur le web
> <https://velobs.2p2r.org/> ou sur android
> <https://play.google.com/store/apps/details?id=org.deuxpiedsdeuxroues.velobs.tlse&hl=fr> (une
> appli 2P2R <https://2p2r.org/>)
> Pedibus labégeois <https://emilepattesblog.wordpress.com/>
> Soutenez ICEA <http://icea-enr.fr/>, Inititiative Citoyenne pour une
> Energie Alternative, prenez ou offrez des parts sociales pour devenir
> co-propriétaire de panneaux photovoltaïques
> Consommez de l'énergie éléctrique verte renouvelable avec ENERCOOP
> <http://www.enercoop.fr/>
>
>


-- 
VelObs : remontez vos problèmes lors des déplacements à vélo sur le web
<https://velobs.2p2r.org/> ou sur android
<https://play.google.com/store/apps/details?id=org.deuxpiedsdeuxroues.velobs.tlse&hl=fr>
(une
appli 2P2R <https://2p2r.org/>)
Pedibus labégeois <https://emilepattesblog.wordpress.com/>
Soutenez ICEA <http://icea-enr.fr/>, Inititiative Citoyenne pour une
Energie Alternative, prenez ou offrez des parts sociales pour devenir
co-propriétaire de panneaux photovoltaïques
Consommez de l'énergie éléctrique verte renouvelable avec ENERCOOP
<http://www.enercoop.fr/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapbender_users/attachments/20180626/01ffd1a9/attachment.html>


More information about the Mapbender_users mailing list