Select to view content in your preferred language

please help me! how to show infoTemplate in method  function showResults(featureSet)

3407
4
Jump to solution
09-13-2014 03:13 AM
lasinh
by
Occasional Contributor

this is my code. i clicked symbol and show infoTemplate . i want call function showResults(featureSet) show infoTemplate

function showResults(featureSet) {

              

                  //remove all graphics on the maps graphics layer

                  myMap.graphics.clear();      

                  var resultFeatures = featureSet.features;

                  //Loop through each feature returned

                  for (var i = 0, il = resultFeatures.length; i < il; i++) {

                      //Get the current feature from the featureSet.

                      //Feature is a graphic

                      var attr = resultFeatures.attributes;

                      var title = attr.TEN;

                      var content = "Field ID : " + attr.OBJECTID

                    + "<br />Tên: " + attr.TEN

                    + "<br />Địa chỉ : " + attr.TEN

                      //initialize InfoTemplate

                      infoTemplate = new InfoTemplate("Kết quả tìm kiếm:", content);                 

 

 

//                      myMap.infoWindow.setTitle(title);

//                      myMap.infoWindow.setContent(content);

//                      myMap.infoWindow.show(resultFeatures[0].geometry);

 

 

                     var graphic = resultFeatures;

                      graphic.setSymbol(symbol1);

 

 

                   //Set the infoTemplate.

                     graphic.setInfoTemplate(infoTemplate);

 

 

                      //                      //Add graphic to the map graphics layer.

                      //                      myMap.graphics.add(graphic);

                     myMap.graphics.add(graphic);

                      //                     

                      myMap.centerAndZoom(resultFeatures[0].geometry, 7);

                  }

              }

0 Kudos
1 Solution

Accepted Solutions
RiyasDeen
Frequent Contributor

Hi Ia,

If your geometry is expected to points, add below lines after your myMap.centerAndZoom(resultFeatures[0].geometry, 7);

myMap.infoWindow.setFeatures([resultFeatures[0]]);          // Get first feature and add it into an array.

myMap.infoWindow.show(resultFeatures[0].geometry);     // Show info window at the location of your first feature.

This should do the trick.

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

Can you provide a Place or Space where you would like this redirected.  Also, providing some tags for your post in the tags section would facilitate getting an answer

lasinh
by
Occasional Contributor

my problem is how to show symbol and infotemplate  that no click symbol.

0 Kudos
RiyasDeen
Frequent Contributor

Hi Ia,

If your geometry is expected to points, add below lines after your myMap.centerAndZoom(resultFeatures[0].geometry, 7);

myMap.infoWindow.setFeatures([resultFeatures[0]]);          // Get first feature and add it into an array.

myMap.infoWindow.show(resultFeatures[0].geometry);     // Show info window at the location of your first feature.

This should do the trick.

lasinh
by
Occasional Contributor
Re: please help me! how to show infoTemplate in method  function showResults(featureSet)

Riyas, it works exactly as I expected.I hope these help you later. thanks Riyas...

0 Kudos