|
POST
|
You have to loop through your results then push them into an object to be used for the showfeature function. here is a little of the code. Granted this is inside a custom function.
/***** this would be in your function to create the infowindow ****/
// "results" would be the response from your query
StFeatures = results.features;
StResults = {displayFieldName: null, features:[]};
for (var i = 0; i < scount; i++)
{
var sResult = StFeatures;
//alert(sResult);
if (!StResults.displayFieldName){ StResults.displayFieldName = sResult.displayFieldName }
StResults.features.push(sResult);
}
var stlist = streetList(StResults); // create list to populate the div
$("#stlist").html(stlist); //jQuery to fill div with id stlist with the table... can use arcgis function for this also
$("#stlist").show("slow"); //jQUery to show the datagrid which is hidden by default
/******* End ******/
function streetList(results)
{
var template = "";
var sn = results.features;
template = "<i>Streets Found: " + sn.length + "</i>";
template += "<table border='1'>";
template += "<tr>"
template += "</tr>";
for (var i = 0, il = sn.length; i < il; i++)
{
template += "<tr>";
template += "<td>"+ sn.attributes["FULLADDRESS"] +"</td>";
template += '<td><a href="#" onclick="featureZoom(StResults.features['+ i +']); return false;">(Zoom To)</a></td>';
template += "</tr>";
}
template += "</table>";
return template;
}
function showFeature (feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
if(ftype == "point")
{
feature.setSymbol(psymbol)
setTimeout(function(){map.graphics.clear()}, 3000);
} else {
feature.setSymbol(symbol);
setTimeout(function(){map.graphics.clear()}, 3000);
}
map.graphics.add(feature);
}
function featureZoom(feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
//console.log(result);
if(ftype == "point")
{
var pt = feature.geometry;
var factor = 1; //some factor for converting point to extent
var extent = new esri.geometry.Extent(pt.x - factor, pt.y - factor, pt.x + factor, pt.y + factor, pt.spatialReference);
map.setExtent(extent.expand(60));
showFeature(feature);
} else {
var fExtent = feature.geometry.getExtent().expand(3);
map.setExtent(fExtent);
showFeature(feature);
}
}
Hopefully you can dismantle my logic LOL I use 2 functions to zoom to the feature one to zoom to the feature "featureZoom" the other to highlight the feature for a couple seconds "showFeature". Ray
... View more
05-05-2014
09:07 AM
|
0
|
0
|
767
|
|
POST
|
@pacofa Without seeing the results returned from your query it is hard to help. But you may have to check the geometry being returned, check to see if more than one, and if so loop through and create your extent based off those results. @mcplng My want to start your own tread if not having the same issue the author has. That way the help provided is not being bounced back and forth. But to answer your question I use this to zoom to features. You have to use a different set of functions to zoom to a point.
symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 255, 255]), 5),
new Color([255, 255, 0, 0.25])
);
psymbol = new SimpleMarkerSymbol(
SimpleMarkerSymbol.STYLE_CIRCLE, 8,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([0, 255, 255]), 8),
new Color([255, 255, 0, 0.25])
);
function featureZoom(feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
//console.log(feature);
if(ftype == "point")
{
var pt = feature.geometry;
var factor = 1; //some factor for converting point to extent
var extent = new esri.geometry.Extent(pt.x - factor, pt.y - factor, pt.x + factor, pt.y + factor, pt.spatialReference);
map.setExtent(extent.expand(60)); // change this control the zoom
showFeature(feature);
} else {
var fExtent = feature.geometry.getExtent().expand(3);
map.setExtent(fExtent);
showFeature(feature);
}
}
function showFeature (feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
if(ftype == "point")
{
feature.setSymbol(psymbol)
setTimeout(function(){map.graphics.clear()}, 3000);
} else {
feature.setSymbol(symbol);
setTimeout(function(){map.graphics.clear()}, 3000);
}
map.graphics.add(feature);
}
The showfeature function just highlights the feature for 3 seconds. The colors can be set by changing the symbol and psymbol variables. Ray
... View more
05-05-2014
04:54 AM
|
0
|
0
|
767
|
|
POST
|
I had this happen to me. In my case it was because of a toolbar I had at the top of my map and the order in which the divs were placed on the web page. The divs you use for each element should not be blocking your map, or should I say, behind your map. If you have some divs that are hidden show them for time being so you can figure out which one is causing the issue. Once found you would assign a style of "position:absolute;" to fix the problem. Mine was caused by a jquery dropdown menu which cause my mouse to be about 6 inches off. If you have some code for the page I can take a look. Ray
... View more
05-05-2014
04:39 AM
|
0
|
0
|
709
|
|
POST
|
Add this to the top of your pages and see what you get. [PHP]ini_set ("display_errors", "1"); error_reporting(E_ALL);[/PHP] let me know if any error show. Ray
... View more
04-29-2014
04:16 AM
|
0
|
0
|
2024
|
|
POST
|
I just remembered another thing. You should make sure the path to the session data is writable by the server. To find out the path you can run the phpinfo() function. A short ways down should be a section which looks like the image attached. go to the path and make sure the IUSR account has write access. Also since you will be using a php form and ldap to authenticate you should shut off windows authentication in the web server and use anonymous authentication. You can change these values in the php.ini file. Don't forget to restart IIS to have them take effect. Ray
... View more
04-28-2014
12:02 PM
|
0
|
0
|
2024
|
|
POST
|
Very weird. There is no need to pass session variables to other pages. As long as the session has been started you should be able to view them simply by calling them. can you post a bit of your code so I can take a look? Ray
... View more
04-28-2014
11:50 AM
|
0
|
0
|
2024
|
|
POST
|
Also you do not need to put session_start() at the top of the functions.php page. since this is a required page the session has already been started by the parent page. Ray
... View more
04-28-2014
11:44 AM
|
0
|
0
|
43583
|
|
POST
|
Not sure if you copied and pasted everything but looking through my code I made a typo. 😞 do_login.php [PHP]session_start(); require('functions.php'); // Process login $postdata = $_POST; do_login($postdata['username'], $postdata['password'], $postdata['redirect']);[/PHP] This actually sends you in a loop because you would never get authenticated so the session is never set and you end up on the login page forever. Let me know. Ray
... View more
04-28-2014
11:42 AM
|
0
|
0
|
43583
|
|
POST
|
We don't use a windows domain here but after some reading it seems the best solution is to use ldap. PHP requires you just un-comment the ldap.dll in php.ini and ldap is on by default in active directory. That being said I would put my functions in a separate file so that they may be used throughout your application. functions.php [PHP] function login_check() { if (isset($_SESSION['IWP_loggedIn']) && $_SESSION['IWP_loggedIn'] === true && isset($_SESSION["IWPUser"])) { return true; } else { return false; } } function do_login($username, $password, $redirect) { $un = $username; // This may need to change. you may have to append the domain ie. mydomain\username $pw = $password; if(empty($un)) { header("Location: http://example.com/login.php?error=Username cannot be blank"); exit(); } if(empty($pw)) { header("Location: http://example.com/login.php?error=Username cannot be blank"); exit(); } $server = "ldaps://yourservernamehere"; //IP or name of server here //echo $server; if (!($ldap = ldap_connect($server))) { header("Location: http://example.com/login.php?error=Could Not Connect To Server"); // can change these error messages exit(); } if (!ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3)) { header("Location: http://example.com/login.php?error=Could Not Connect To Server"); exit(); } if (!($res = @ldap_bind($ldap, $un, $pw))) { header("Location: http://example.com/login.php?error=Could Not Connect To Server"); exit(); } else { $_SESSION['IWP_loggedIn'] = true; $_SESSION["IWPUser"] = $username; header("Location: ".$redirect); } } function do_logout($redirect) { session_destroy(); header("Location: ".$redirect); }[/PHP] now you can require this file at the top of all your pages so that the functions can be used. login.php [HTML]<?php $error = isset($_GET['error']) ? $_GET['error'] : ""; ?> <style type="text/css"> /* Login Form style */ #loginform { font-size: 14px; text-align: center; width: 480px; position: fixed; /*display: none;*/ background-color: #EEEEEE; border-radius: 13px; border: 2px solid #3399CC; top: 40%; left: 36%; z-index: 200; box-shadow: 10px 10px 10px black; } #loginform .form_header { border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom: none; width: 480px; height: 30px; line-height: 19px; vertical-align: middle; background-color: #3399CC; text-decoration: none; font-family: Times New Roman, Serif; font-weight: 900; font-size: 18px; text-align: left; padding-top: 5px; color: #FFFFFF; cursor: default; } #loginform .form_body { width: 400px; border: 1px solid black; background-color: #FFFFFF; } #loginform .status { width: 400px; margin: 10px auto 0 auto; } #loginform input { margin: 5px; padding: 0px; float: left; border: 1px solid #cdcdcd; background-color: white; border-radius: 2px; } /* 'Login' Button */ #submit { margin: 5px; padding: 0px; float: left; width: 50px; background-color: white; } </style> <div id="loginform" style="" > <div class="form_header" id="popup_drag" > <span style="margin-left:5px;">Employee Login</span> </div> <div class="status"> <fieldset> <legend align="center">Authentication</legend> <form id="login" name="login" method="post" action="/do_login.php" > <input type="hidden" name="redirect" value="/gis"/> <table align="center" width="300" border="0"> <tr> <td width="80">Username</td> <td><input id="name" type="text" name="username"></td> </tr> <tr> <td>Password</td> <td><input type="password" name="password"></td> </tr> <tr> <td> </td> <td><input id="submit" class="login-submit" type="submit" name="submit" value="Login"></td> </tr> </table> </form> </fieldset> </div><br><span style="color:red;"><?php echo $error;?></span> </div>[/HTML] do_login.php [PHP] session_start(); require('functions.php'); // Process login $postdata = $_POST; do_login($postdata['username'], $postadat['password'], $postdata['redirect']);[/PHP] Very simple. You can add in some messages if you like. Then at the top of all your pages just run a login check [PHP]session_start(); require('functions.php'); if(login_check() === false) { header("Location: http://example.com/login.php"); exit(); } else { // rest of your page below } [/PHP] I have not tested every part of this but once you implement it you can post any errors here and I will help out best I can. Don't forget to start all your pages with session_start(); just incase I forgot to add it to any of the pages. Also remember to change all your header locations. Hope that gets you going. Ray
... View more
04-25-2014
06:16 AM
|
0
|
0
|
43583
|
|
POST
|
Do you have any code for this as of yet?? If you do please post. I am an experience PHP coder and should be able to help. Ray *EDIT* try taking a look here http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/enable-php-applications-to-make-application-level-access-control-decisions
... View more
04-24-2014
04:52 AM
|
0
|
0
|
43583
|
|
POST
|
You look to be using jQuery code to get the value. Is your code encased in jQuery document ready?. If not $('#searchType').val(); will not work. Use var searchOptions = jQuery('#searchType').val(); or var searchOptions = registry.byId("searchType").get("value"); If you are not getting a value for searchOptions it will return null because you don't have a default for your switch. Ray
... View more
04-17-2014
06:24 AM
|
0
|
0
|
461
|
|
POST
|
Can you get the error from the click. If using firefox get/open firebug and there should be an error in the console. If using IE hit f12 to bring up the developer tools and see what the error is. Post when you get it. Ray
... View more
04-16-2014
09:28 AM
|
0
|
0
|
2149
|
|
POST
|
I am a little confused on your flow. How is the buffer and selection being done? Do you want to run an identify of the buffer that was previously created or is this all going to be done at the same time? Ray
... View more
04-16-2014
09:25 AM
|
0
|
0
|
1196
|
|
POST
|
The only difference I see is that the featureZoom function is within the require section of your ArcGIS. Try moving id down to where your jquery is for the search submittable.
<script>
$("#search").bind( "click", function() {
map.graphics.clear();
//var stnum = registry.byId("addnum").get("value");
var stname = $("#streetName").val();
//var stcity = registry.byId("addcity").get("value");
AddressSearchTask("", stname, "");
});
//Zoom to the parcel when the user clicks a row
function featureZoom(feature)
{
map.graphics.clear();
ftype = feature.geometry.type;
console.log(ftype);
if(ftype == "point")
{
var pt = feature.geometry;
var factor = 1; //some factor for converting point to extent
var extent = new esri.geometry.Extent(pt.x - factor, pt.y - factor, pt.x + factor, pt.y + factor, pt.spatialReference);
map.setExtent(extent.expand(60));
showFeature(feature);
} else {
var fExtent = feature.geometry.getExtent().expand(3);
map.setExtent(fExtent);
showFeature(feature);
}
}
function showFeature (feature)
{
console.log('showFeature');
map.graphics.clear();
ftype = feature.geometry.type;
if(ftype == "point")
{
feature.setSymbol(psymbol)
setTimeout(function(){map.graphics.clear()}, 3000); // 3000 is a timeout to show the feature then clear it. change to liking
} else {
feature.setSymbol(symbol);
setTimeout(function(){map.graphics.clear()}, 3000); // 3000 is a timeout to show the feature then clear it. change to liking
}
map.graphics.add(feature);
}
</script>
Ray
... View more
04-15-2014
06:37 AM
|
0
|
0
|
2149
|
| Title | Kudos | Posted |
|---|---|---|
| 3 | 09-08-2017 07:16 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-03-2025
07:10 AM
|