Retain popup data after it is closed

1664
24
Jump to solution
04-01-2020 08:50 PM
rsharma
Occasional Contributor III

I want to retain popupdata which i filled in it, when i close the popup coming from marker symbol , and again open it, my popup refreshed.??

0 Kudos
24 Replies
RobertScheitlin__GISP
MVP Emeritus

The simple answer is that you assign a unique id as an attribute to the graphic when it is added to the GL.

rsharma
Occasional Contributor III

i removed clone fnc bcz i need to drop different marker every time on mouse click

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rajni,

   You have a lot of unneeded redundancy in your code right now.

view.toMap({x:evt.x, y: evt.y})

This portion produces a point class in WKID 102100 (web mercator).

So there is no need for all this code:

var coords = "Lat/Lon " + pt.latitude + " " +pt.longitude;
/* console.log(markertype+" "+comment);*/
var p = new Point({
  longitude: pt.latitude,
  latitude: pt.longitude,
  spatialReference: {wkid: 4326}
});

So your code would look like this instead:

view.on("click", function(evt) {
  if(getmarkerclick==true){
    var p = view.toMap({x:evt.x, y: evt.y});
    var changedSymbol = changedsymbol(markertype);
    var g = new Graphic({
      geometry: p,
      symbol: changedSymbol,
      attributes: {
        newDevelopment: "new marker",
        state: "new",
        uniquetype: markertype,
        markerId: "static",
        comment: comment
      }
    });
  }
}); //End view click‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I assume that "markertype" is a global var somewhere else in your code?

rsharma
Occasional Contributor III

Got you sir,

Just one more thing pls tell  me how to loop through all markers attributes., i need to save them all with its attributes in db

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

??? You know how to loop through the graphics in the markerGL right then inside that loop you have a refereence to the graphic and each graphic has attributes object and because you have a limited set of predefined attributes you just get the value of each attribute by name.

graphic.attributes.markerId,

graphic.attributes.comment,

etc.

rsharma
Occasional Contributor III

Ok Why my marker is not cllickable when added on editable polygon, i have to click outside on map ,after that my marker clicks enable.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

That's just how it works.

0 Kudos
rsharma
Occasional Contributor III

Can i make marker clickable by  showing it uneditable all the time, when i click on polygon, then only it should be editable, so that my markers work fine.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yep. What is making your markers not clickable is the fact that when you are editing a geometry it disables the webmap popups.

rsharma
Occasional Contributor III

yes you are right, polygons stays editable all the time, if it is possible to make it editable only on polygon click,

0 Kudos