Select to view content in your preferred language

Show popups without moving map

2367
25
07-21-2011 01:35 PM
BenReilly
Emerging Contributor
I have an issue with the way popups display in the javascript api. I can't get popups to show up for my feature layers unless the map is moved first. I need to make a map that has disabled scrolling, so how can I get popups to display without the map moving first?
0 Kudos
25 Replies
derekswingley1
Deactivated User
Is this still the link to see your issues: http://arcviewdev.uww.edu/javamap.html

That page doesn't load a map for me and is using 2.3.
0 Kudos
DavidMurray
Emerging Contributor
Hi

That's not the link to my site.  Unfortunately whilst the site is being developed the systems administrator has password protected the mapping services.  So I can't supply a link to the current application.  However here is the code for the function that is handling the click event.

function checkAuthority(event){
  qBuffer.geometry = event.mapPoint;
   //execute query
   qTaskBuffer.execute(qBuffer,function(featureSet){
    //show pop-up if location does not intersect road buffer layer
    if(featureSet.features.length===0){
     map.infoWindow.setTitle("Warning");
     map.infoWindow.resize(300,250);
     map.infoWindow.setContent("The location you have selected is not on a road, please try marking the defect again.");
     map.infoWindow.show(event.mapPoint);
     document.getElementById("loadingLayer").style.display = "none";
     if(mapscale>2000){map.setLevel(12);}  //level 12 is 1:2,000
     closeResults();
    }else if(featureSet.features.length===1){//function to display one result only
     displayResult(featureSet.features[0],event);
    }else{//call function to display multiple results
     displayResults(featureSet,event);
    }
   });

}



Basically it checks that the mouse click intersects a polygon layer.  If it does then the results are verified then displayed to the user.  If the location of the mouse click does not intersect the polygon layer a message is displayed to the user. 

Currently this works fine if the user has zoomed or panned around the map, however if they click on the map once the data has loaded and have not panned or zoomed it returns an error.   I have trapped the error using the "onError" event of the qTaskBuffer, but the message property of the error object is empty and it does not recognise the instance type.  Using the onError event has allowed me to prompt the user to click on the map again, they click on the map and the process is successful.

I've tested the application in numerous browsers and different versions of the API and still get the same result. 

Any advice would be very welcome.

Kind regards
David
0 Kudos
derekswingley1
Deactivated User
Thanks for the additional info. Are you able to post the rest of your code?
0 Kudos
DavidMurray
Emerging Contributor
It would not let me post the code, too many characters.  Could I email you directly, that way I could supply you the code and a user name and password so you can access the site? 

Many thanks
David
0 Kudos
derekswingley1
Deactivated User
Hi David,

Sent you a message on twitter.
0 Kudos
DavidMurray
Emerging Contributor
Thanks to Swingley the issue has been resolved.

The cause was the spatial reference of the geometry being pasred into the querytask was null.  So to resolve this I created a new point object allowing me to set the spatial reference.  This point object is then used to set the geometry property of the querytask

var click_point= new esri.geometry.Point(event.mapPoint.x,event.mapPoint.y, new esri.SpatialReference({wkid:27700}));
qAuth.geometry=click_point;


Thank you for all the help.
0 Kudos