Create a marker using people's initials

612
3
Jump to solution
04-06-2017 10:54 AM
by Anonymous User
Not applicable

Hi all,

Is there a way in Javascript and ESRI's api to get the fullname column from my Feature layer's column, transform the full names into initials and render it in a marker that would have people's initials?

Thanks,

Alex

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Alex,

   Sure once you have the name value from the attribute just split the string based on " " (spaces) and then get the first letter using .substring(1, 1); and save that to a new string to concatenate with the other first letters and then use a TextSymbol

TextSymbol | API Reference | ArcGIS API for JavaScript 3.20 

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Alex,

   Sure once you have the name value from the attribute just split the string based on " " (spaces) and then get the first letter using .substring(1, 1); and save that to a new string to concatenate with the other first letters and then use a TextSymbol

TextSymbol | API Reference | ArcGIS API for JavaScript 3.20 

View solution in original post

by Anonymous User
Not applicable

I am now getting the initials in a variable but at the end of the loop I get an error:

Here is my code:

queryTaskauto.execute(queryauto, function (results) {
               
                arrayUtil.forEach(results.features, function(value, index){
               
                var arraynew = value.attributes.f3;
                var words = arraynew.split(' ');
                var text = '';
                $.each(words, function () {
                text +=  this.substring(0, 1);
                });
               
                console.log(text);
                console.log(words);

               
               
                });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Any idea?

0 Kudos
by Anonymous User
Not applicable

This worked:

if (arraynew === null){
                console.log("Dont split");
                } else {
               
                var words = arraynew.split(' ');
                var text = '';
                $.each(words, function () {
                text +=  this.substring(0, 1);
                });
               
                console.log(text);
                console.log(words);
                }