Select to view content in your preferred language

Non Address information on the infotemplate to be linked to the addresses located

638
1
02-06-2014 07:34 PM
sunithanaik
Emerging Contributor
Hi,

I am trying to link Account Name to accounts whose addresses are located on a map by using the addresstolocate(accountaddress) using arcgis javascrip API. However,the functions linked to this has information about address,score and location.

How Can I pass account name information so that the address lcoated on the map corresponding to the account is displayed on the map.

here is further details.

address 2 is the account address that got by iterating the result set from the sql query.

locator1.addressToLocations(address2);
       locator1.on("address-to-locations-complete", showResultsAcc);

i want to pass account name to few more parameter to the infotemplate by using the html variable

var html3="<div style=\"float:left;\"><div style=\"font-family: arial, san-serif; padding-left:30px;\"><span style=\"font-weight:bold;\"><a href='https://community.esri.com/{!account.ID}' target='_blank'>{!account.Name} </a></span><br/>";

however only a single/last account name is getting linked to the template and it is not dispalying the account name for all the located addresses.

Please Note: WHen there is an alert () message between the start on the ShowTResult functions teh functioanloty workes but without alert it does not. So I thought it might be due to some delay in the world geocode service and addes some delay but that did not work for me.

Request you to please provide a solution as I have spent a lot of time on this.


The ShowResultsAcc does the task of adding the graphic to the map with the information template.

function showResultsAcc(evt) {
   
    //alert('Inside acc');
          var candidate;
          var infoTemplate = new InfoTemplate(
            "Location",
            "Address: ${address}<br />Score: ${score}<br />"
          );
       

          var geom;

                var symbol3 = new esri.symbol.PictureMarkerSymbol('https://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png', 32, 32);
//alert('symbol3'+symbol3);
                
      
       //alert('html acc'+html3);       

       var attribute3 = {
                "AccInfo": html3
              };
    
         //alert('acc attribute3'+attribute3);      
  
  
            var infoTemplate3 = new InfoTemplate(
            "Account Info",
            "${AccInfo}<br/>"
          );
     
          //alert('infotemplate acc '+infoTemplate3);
   
          arrayUtils.forEach(evt.addresses, function(candidate,index) {
            console.log(candidate.score);
            if (candidate.score > 80) {
  
              console.log(candidate.location);
    
     //alert('score greater account'+candidate.geometry);
    
              var attributes = {
                address: candidate.address,
               
               
              };  
             
    geom = candidate.location;
   
   
  
              //alert('geom in Acc'+geom);
             
              var graphic3 = new esri.Graphic(geom,symbol3,attribute3,infoTemplate3);
              //alert('acc graphics'+graphic3);
             
              //add a graphic to the map at the geocoded location
              map.graphics.add(graphic3);
    
  dojo.connect(map.graphics, "onMouseMove", function(evt) {
          var g = evt.graphic;
          map.infoWindow.setContent(g.getContent());
          map.infoWindow.setTitle(g.getTitle());
          map.infoWindow.show(evt.screenPoint,map.getInfoWindowAnchor(evt.screenPoint));
        });
        dojo.connect(map.graphics, "onMouseOut", function() {map.infoWindow.hide();} );
         
              return false; //break out of loop after one candidate with score greater  than 80 is found.
            }
0 Kudos
1 Reply
daniellabirch
New Contributor
I have a similar problem passing variables through the infoTemplate. Its like there's something funny happening with the scope. Certain variables work but when I get too crazy with them my map doesn't load.

Example1 works:
template = new InfoTemplate({
title: welltitle,
content: "ID: "+coords[0]+"<br />"+coords[0]+"<br /><a href='http://waterdata.usgs.gov/nwis/dv/?site_no="+coords[0]+"&agency_cd=USGS&amp;referred_module=sw' target='_blank'><img width='100%' src='http://waterdata.usgs.gov/nwisweb/graph?agency_cd=USGS&site_no="+coords[0]+"&parm_cd=72019&period=7' /></a>"+datatext
});

Example2 does not:
template = new InfoTemplate({
title: welltitle,
content: "ID: "+coords[i+1][0]+"<br />"+coords[i+1][0]+"<br /><a href='http://waterdata.usgs.gov/nwis/dv/?site_no="+coords[i+1][0]+"&agency_cd=USGS&amp;referred_module=sw' target='_blank'><img width='100%' src='http://waterdata.usgs.gov/nwisweb/graph?agency_cd=USGS&site_no="+coords[i+1][0]+"&parm_cd=72019&period=7' /></a>"+datatext
});
0 Kudos