Select to view content in your preferred language

Identify infowindow missing "zoom to" & highlight

1306
9
Jump to solution
08-11-2014 10:23 AM
MayJeff
Deactivated User

I try to identify a parcel and return results on the same infowindow but missing a "Zoom to" link and can't figure out how to highlight a parcel only.

I put the code here:

Edit fiddle - JSFiddle

Hope someone can show me what I am missing...

Thanks.

0 Kudos
1 Solution

Accepted Solutions
RiyasDeen
Frequent Contributor

for some reason formatting was completely off in my previous post.

            function showIdentifyResults(r, tasks) { 

                var results = []; 

                var taskUrls = []; 

                r = dojo.filter(r, function (result) { 

                    return r[0]; 

                }); 

                for (i = 0; i < r.length; i++) { 

                    results = results.concat(r); 

                    for (j = 0; j < r.length; j++) { 

                        taskUrls = taskUrls.concat(tasks.url); 

                    } 

                } 

        

  //combine content -------------------

   var content = parcels = buildings ="";

              var parcelFeatures = [];

   dojo.forEach(results, function(result) {     

    var feature = result.feature;

  var atts = feature.attributes;

  feature.attributes.layerName = result.layerName;

  if(result.layerName === 'Tax Parcels'){

   parcels += atts["Postal Address"] + "<br />";

                  parcelFeatures[parcelFeatures.length] = result.feature;

  }

  else if (result.layerName === 'Building Footprints'){

   buildings += "Building/Parcel ID: " + atts.PARCELID + "<br />";

  }

   });

  if ( parcels ) {

  content += "<b>Parcels</b><br />" + parcels;

   }

   if ( buildings ) {

  content += "<b>Buildings</b><br />" + buildings;

   }

   console.log("content:  ", content);

   map.infoWindow.setTitle("Parcel Information");

  

   map.infoWindow.setContent(content);

   //map.infoWindow.show(idPoint);

  

  

    if (results.length === 0) { 

                    map.infoWindow.clearFeatures(); 

                } else { 

                     map.infoWindow.setFeatures(parcelFeatures);

                     map.infoWindow.setContent(content);

                } 

                map.infoWindow.show(idPoint); 

                return results;

            } 

View solution in original post

0 Kudos
9 Replies
RobertScheitlin__GISP
MVP Emeritus

May Jeff,

   You will not get the zoom to or feature highlight without setting the infoWindows.setFeatures method. More like this sample: Display identify results in popup | ArcGIS API for JavaScript

MayJeff
Deactivated User

if I set the infoWindows like this - 

map.infoWindow.setFeatures(results);

Nothing shows up anymore. Can you show me on the JSFiddle?  Thanks.

0 Kudos
KenBuja
MVP Esteemed Contributor

This gets you closer, but it also returns the layers you haven't supplied content for.

MayJeff
Deactivated User

Thanks for your sample.  Eventhough I define the layerName I want, but it still shows up all layers.  Can you show me how to exclusive some layer names?

Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

May Jeff,

   Here is a fiddle that only does the parcels (i think the way you want).

JSFiddle Link

0 Kudos
MayJeff
Deactivated User

Actually I try to identify multiple map services with certain layer names with their attributes to show up in ONE page infoWindow and then only highlight parcel polygon.

I only find out I can use content to do it but won't highlight any result at all based on the Robert mentioned above - NEED map.infoWindow.setFeatures(results).  I used the sample you all shows on JSFiddle, I can't show all attributes information in one page.  What do I need to modify it so can show all results in one page?

Thank you for your time.

0 Kudos
RiyasDeen
Frequent Contributor

Hi Jeff,

If below is the result you are looking for combined info result with zoom to.

_Untitled.png

Below is your modified showIdentifyResults (inserted lines 17, 24, 47)

            function showIdentifyResults(r, tasks) { 

                var results = []; 

                var taskUrls = []; 

                r = dojo.filter(r, function (result) { 

                    return r[0]; 

                }); 

                for (i = 0; i < r.length; i++) { 

                    results = results.concat(r); 

                    for (j = 0; j < r.length; j++) { 

                        taskUrls = taskUrls.concat(tasks.url); 

                    } 

                } 

        

  //combine content -------------------

   var content = parcels = buildings ="";

              var parcelFeatures = [];

   dojo.forEach(results, function(result) {     

    var feature = result.feature;

  var atts = feature.attributes;

  feature.attributes.layerName = result.layerName;

  if(result.layerName === 'Tax Parcels'){

   parcels += atts["Postal Address"] + "<br />";

                  parcelFeatures[parcelFeatures.length] = result.feature;

  }

  else if (result.layerName === 'Building Footprints'){

   buildings += "Building/Parcel ID: " + atts.PARCELID + "<br />";

  }

   });

  if ( parcels ) {

  content += "<b>Parcels</b><br />" + parcels;

   }

   if ( buildings ) {

  content += "<b>Buildings</b><br />" + buildings;

   }

   console.log("content:  ", content);

   map.infoWindow.setTitle("Parcel Information");

  

   map.infoWindow.setContent(content);

   //map.infoWindow.show(idPoint);

  

  

    if (results.length === 0) { 

                    map.infoWindow.clearFeatures(); 

                } else { 

                     map.infoWindow.setFeatures(parcelFeatures);

                     map.infoWindow.setContent(content);

                } 

                map.infoWindow.show(idPoint); 

                return results;

            } 

0 Kudos
RiyasDeen
Frequent Contributor

for some reason formatting was completely off in my previous post.

            function showIdentifyResults(r, tasks) { 

                var results = []; 

                var taskUrls = []; 

                r = dojo.filter(r, function (result) { 

                    return r[0]; 

                }); 

                for (i = 0; i < r.length; i++) { 

                    results = results.concat(r); 

                    for (j = 0; j < r.length; j++) { 

                        taskUrls = taskUrls.concat(tasks.url); 

                    } 

                } 

        

  //combine content -------------------

   var content = parcels = buildings ="";

              var parcelFeatures = [];

   dojo.forEach(results, function(result) {     

    var feature = result.feature;

  var atts = feature.attributes;

  feature.attributes.layerName = result.layerName;

  if(result.layerName === 'Tax Parcels'){

   parcels += atts["Postal Address"] + "<br />";

                  parcelFeatures[parcelFeatures.length] = result.feature;

  }

  else if (result.layerName === 'Building Footprints'){

   buildings += "Building/Parcel ID: " + atts.PARCELID + "<br />";

  }

   });

  if ( parcels ) {

  content += "<b>Parcels</b><br />" + parcels;

   }

   if ( buildings ) {

  content += "<b>Buildings</b><br />" + buildings;

   }

   console.log("content:  ", content);

   map.infoWindow.setTitle("Parcel Information");

  

   map.infoWindow.setContent(content);

   //map.infoWindow.show(idPoint);

  

  

    if (results.length === 0) { 

                    map.infoWindow.clearFeatures(); 

                } else { 

                     map.infoWindow.setFeatures(parcelFeatures);

                     map.infoWindow.setContent(content);

                } 

                map.infoWindow.show(idPoint); 

                return results;

            } 

0 Kudos
MayJeff
Deactivated User


Thank you very much.  This is what I need.

0 Kudos