03-07-2018 08:44 PM - edited 03-07-2018 08:46 PM
I have javacsript code to find all parcels intersecting with a line or a polygon that the user enters
$GP.map.draw.clear(); $GP.ui.info("Click to draw shape"); $GP.map.draw({ type: "Polygon" }, function (r) { var coords = r.feature.get_geoJSON().geometry.coordinates; // coordinates order may vary depending on the CRS definition createAnalysis(r.feature.get_geoJSON().geometry);
and it works fine on Chrome and Firefox. It has been tested a lot on these two browsers and never fails. On IE11 the red line that the user starts to draw does not appear. Rarely it will appear if Developer Tools are turned on.but then there is an error in the Developers Debug Console. (Attached here)
Other code that finds parcels interesecting with a circle where the user just clicks on a point and enters a radius value to define the circle works fine. The circle points are then calculated based on the center clicked. The difference is that the line and polygon code has to find the coordianates of all the points. Any idea what could be causign the error in IE11 and also EDGE
03-08-2018 12:03 AM
Hi Jane,
It works fine for me:
Although there are some caveats:
03-08-2018 05:00 AM - edited 03-08-2018 05:54 AM
Thanks - I;m not running in IE in compatibility mode or using console references and I see that the redlining examples provided from examplesess.aspx work fine on IE 11 so it must be something in my code.
This is an extremely simplified listing of it that has most of the code removed and still fails
function SelectByLine_TEST() {
$GP.map.draw.clear();
$GP.ui.info("Click to draw line");
$GP.map.draw({ type: "LineString" },
function (r) {
var coords = r.feature.get_geoJSON().geometry.coordinates;
// coordinates order may vary depending on the CRS definition
createAnalysisxx(r.feature.get_geoJSON().geometry);
});
function createAnalysisxx(geometry) {
var geometry2 = geometry.coordinates[0].reduce(function (prev, current) {
return prev = prev.concat(current)
}, []),
ab = JSON.stringify([geometry]).slice(37, -23);
$GP.ui.info(ab);
$GP.ui.info("# of points entered = " + coords.length);
var coordArray = JSON.parse("[" + ab + "]");
}
};
03-08-2018 06:53 AM
I've reduced the code to shown below and it is still failing. I'm sure it is getting to this code (changed the $GP.ui.info message)
One time it worked when I had the $GP.map.draw.clear(); commented out but after that it did not.
I am sure compatibility mode is off including for the local machine ( i am running with just the machine name in the url as it is behind a firewall). This same code does work with the Examples (i copied it from there)
function SelectByLine_ORIGINAL() { // $GP.map.draw.clear(); $GP.ui.info("Click to draw a line"); $GP.map.draw({ type: "LineString" }, function () { $GP.ui.info("The path has been drawn"); });
03-08-2018 06:56 AM - edited 03-08-2018 06:56 AM
How do you actually run it? Can you perhaps create a simplet JS file that will add a button (such as HelloWorld.js), add this code to the file and reference the file in other ASPX page, such as Full.aspx? In order to get rid of influence of other custom script files.
It could be something else breaking the functionallity.
03-08-2018 07:02 AM - edited 03-08-2018 07:05 AM
I run it from a button. The example with the same code works in my gwmpub.aspx session with same maps. The error message i get from the debugged is always the same as the one i posted at the start.
I have only 5 lines of code now!
It works fine on Chrome and FireFox
This is all the code assigned to the button and i do get the message to Enter the points so the code is being reached and i am sure it is the right code being reached by the message that is displayed...
function SelectByLine_ORIGINAL() { // $GP.map.draw.clear(); $GP.ui.info("Click to draw a line"); $GP.map.draw({ type: "LineString" }, function () { $GP.ui.info("The path has been drawn"); });
Once it worked when i had the $GP.map.draw.clear(); commented out and i was sure that was it but it is failing again (still working fine on other browsers)
03-08-2018 07:06 AM
What I meant was to make sure there is as few custom script files referenced as possible, in this ASPX page section:
<asp:ScriptManager runat="server" EnableScriptGlobalization="true" EnableScriptLocalization="true"> <Scripts> <asp:ScriptReference Path="js/MapConfig.js" /> <asp:ScriptReference Path="js/LayoutHelper.js" /> <asp:ScriptReference Path="js/API.min.js" /> <asp:ScriptReference Path="js/StyleConfig.js" /> <asp:ScriptReference Path="js/HelloWorld.js" />
03-08-2018 07:13 AM
Yes - i have no changes to any of those files except HelloWorld.js In helloworld the only thing i do at startup is to zoom to the area of interest based on bbox in url and determine which buttons to display based on another url parameter (user type)
Are you able to run the very short code from a button? I am thinking something is wrong with my IE but we are using several different versions. I don't know why it works (very rarely)
The error message is always the same
03-08-2018 07:20 AM
Yes, it works fine on my IE11
Can you perhaps try to delete Portal cache (...\src\Application\App_Data\Cache)?
03-08-2018 07:32 AM
Maybe our IE Is out of date
I always get this message:
SCRIPT5007: Unable to get property 'set_visibility' of undefined or null reference
File: Compositor.WebClient.ashx, Line: 67686, Column: 13
The message to start entering the line does display and the cursor changes to +
I deleted the cache you suggested (there were old files there) but it didn't help.
WIll try upgrade to IE