mapsunithakrishna

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

Discussion created by mapsunithakrishna on Feb 6, 2014
Latest reply on Feb 25, 2014 by dbirch@usgs.gov
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='/{!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.
            }

Outcomes