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

Astrid Emde astrid.emde at wheregroup.com
Tue Jun 26 01:13:32 PDT 2018


Hello Gérald,

great to hear that it works fine. The solution with the trigger sounds 
good.

onBeforeInsert should work too. I have to check it when I find the time.

All the best for the next step

Astrid

Am 2018-06-26 07:24, schrieb Gérald Salin:
> 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/library/feature_styling.html [1]
>> 
>> 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.deuxpiedsdeuxroues.velobs.tlse&hl=fr
>> [2]
>> [3] https://2p2r.org/
>> [4] https://emilepattesblog.wordpress.com/ [3]
>> [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 [4]
>> 
>> --
>> Mit freundlichen Grüßen
>> 
>> Astrid Emde
>> Senior GIS-Consultant
>> 
>> -----------------------------------
>> Aufwind durch Wissen!
>> Qualifizierte Open-Source-Schulungen
>> bei der www.foss-academy.com [5]
>> -----------------------------------
>> 
>> 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 [6]
>> 
>> Folgen Sie der WhereGroup auf twitter:
>> http://twitter.com/WhereGroup_com [7]
>> 
>> 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 [4]
> 
> --
> 
> VelObs : remontez vos problèmes lors des déplacements à vélo sur
> le web [8] ou sur android [9] (une appli 2P2R [10])
> Pedibus labégeois [3]
> Soutenez ICEA [11], 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
> [12]
> 
> --
> 
> VelObs : remontez vos problèmes lors des déplacements à vélo sur
> le web [8] ou sur android [9] (une appli 2P2R [10])
> Pedibus labégeois [3]
> Soutenez ICEA [11], 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
> [12]
> 
> 
> 
> Links:
> ------
> [1] http://docs.openlayers.org/library/feature_styling.html
> [2]
> https://play.google.com/store/apps/details?id=org.deuxpiedsdeuxroues.velobs.tlse&amp;hl=fr
> [3] https://emilepattesblog.wordpress.com/
> [4] https://lists.osgeo.org/mailman/listinfo/mapbender_users
> [5] http://www.foss-academy.com
> [6] http://www.wheregroup.com
> [7] http://twitter.com/WhereGroup_com
> [8] https://velobs.2p2r.org/
> [9]
> https://play.google.com/store/apps/details?id=org.deuxpiedsdeuxroues.velobs.tlse&hl=fr
> [10] https://2p2r.org/
> [11] http://icea-enr.fr/
> [12] 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

*********************************************
AGIT 2018
4.- 6. Juli 2018 in Salzburg
Treffen Sie die WhereGroup bei der AGIT EXPO
http://www.agit.at/
*********************************************

  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
-------------------------------


More information about the Mapbender_users mailing list