Hi
A default popup appear when i click on vertice of polygon. As i m also using markers with popup in my app, but they also appear on my vertices with default body.
The line in bold shows my popup, but it should not work for polygon vertices.
// This function is called when a user clicks on the view.
function setUpGraphicClickHandler() {
view.on("click", function(event) {
view.hitTest(event).then(function(response) {
var results = response.results;
if(results.length === 0){
sketchViewModel.complete();
markersketchViewModel.complete();
}
// Check if the new development graphic and temp graphics with attribute named newDevelopment was clicked and pass
// the graphic to sketchViewModel.update() with reshape tool.
results.forEach(function(result) {
if (
result.graphic.layer === sketchViewModel.layer &&
result.graphic.attributes &&
result.graphic.attributes.newDevelopment
) {
sketchViewModel.update([result.graphic], { tool: "reshape" });
} else if(
result.graphic.layer === markersketchViewModel.layer &&
result.graphic.attributes &&
result.graphic.attributes.newDevelopment){
markersketchViewModel.update([result.graphic], { tool: "reshape" });
}
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
// view.popup.open({features: [result.graphic], location: result.graphic.geometry});
} else if(markersketchViewModel!== 'active' ){
markersketchViewModel.cancel();
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
});
});
});
}//End setUpGraphicClickHandler
Solved! Go to Solution.
Well because you are using two SVMs then you need to check the state of both of them like I suggested last post.
Sir
I am already checking the state for both of them, I don't know where i m getting wrong.
Honestly I do not either. If you have vertices showing then one of the SVMs should be active, unless you are manually adding the vertices to some graphics layer.
But i m using this condition, how can a popup appear , if they are active.
I am adding markers with popup on separate layers.
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
//view.popup.open({features: [result.graphic], location: result.graphic.geometry});
} else if(markersketchViewModel.state!== 'active'){
markersketchViewModel.cancel();
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
this is the marker add on click
view.on("click", function(evt) {
if(getmarkerclick==true){
counter++;
getmarkercoordinates(view.toMap({x:evt.x, y: evt.y}));
getmarkerclick=false;
}
}); //End view click
//Plot marker on map on click
window.getmarkercoordinates=function(pt){
var p = new Point({
longitude: pt.longitude,
latitude:pt.latitude,
spatialReference: { wkid: 4326 }
});
var changedSymbol=changedsymbol(markertype);
var g = new Graphic({
geometry: webMercatorUtils.geographicToWebMercator(p),
symbol: changedSymbol,
attributes: {
newDevelopment: "new marker",
state: "new",
uniquetype:markertype,
markerId:"0",
marker_temp_Id:counter,
comment:comment
}
});
//define popup body here
var popup_html = ' <div class="be-form-wrapper">';
popup_html += '<div class="cmt_txt">'+comment +'</div></div>'
popup_html += '<div class="cat-btn-wrapper">';
popup_html += '<button class="btn btn-width close_marker" data-url="">Cancel</button>';
popup_html += '</div> </div></div>';
//add content of popup body here
g.popupTemplate = {
title : ' ',
content: popup_html
};
markerGL.add(g);
};
Rajni,
I think I recommended before that you check the state of both SVMs at the same time not in separate else ifs.
}else if(markersketchViewModel.state!== 'active' && sketchViewModel.state !== 'active'){
if(markersketchViewModel){
markersketchViewModel.cancel();
}
if(sketchViewModel){
sketchViewModel.cancel();
}
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
Well your code blocked my markers also, so i did some minor editing, and now it works fine.
else if(sketchViewModel.state !== 'active'){
sketchViewModel.cancel();
//view.popup.open({features: [result.graphic], location: result.graphic.geometry});
} else if(markersketchViewModel.state!== 'active'){
markersketchViewModel.cancel();
if( result.graphic.attributes &&
result.graphic.attributes.newDevelopment){
view.popup.open({features: [result.graphic], location: result.graphic.geometry});
}
}