Skip to main content

Are there any javascript experts out there? I have created a data download web application where you draw a polygon and return some data. I have done this primarily from some samples made available on the knowledge base. It looks ok I have customized it a bit and added some extra functionality/background mapping.

This is all working very well when I draw my polygon and submit the request it goes to Server and my data returns.

Problem is I want to run the workspace even if a polygon is not defined/drawn - as in I have another parameter option to input x,y min and max values. I would like the workspace to submit without the polygon geometry part being drawn.

 

 

But when I try to do this I get the following error stating it can not read length

mapinfo.js:175 Uncaught TypeError: Cannot read property 'length' of undefined

at processClip (mapinfo.js:175)

at HTMLInputElement.onclick (mapinfo.html:1)

 

 

Can anyone tell me how I could get around this basically if its null ignore or something similar? I have tried a number of things but I am struggling to get anywhere.

 

If I run the url directly with the geom value empty the workspace runs fine

 

http://server/fmedatadownload/repository/workspace.fmw?INPUT_POLYGON=&INSERT_COORDS=&MITAB_VERSION=1150&QUARTER=DLM_CORE_2020Q1&OUTPUT_COORD_SYS=IRELAND-ITM&PRIME2_CLASS_YES_NO=No&CBD2019_YES_NO=Yes&NAME=Ciara Beddy&EMAIL=myemail&CUSTOMER=Test&GEOM=POLYGON(())

 

I have attached the javascript used -- any assistance would be greatly appreciated

I am in no way a javascript expert but have you tried something like

if (clippingGeometry){
var geometry = "POLYGON((";

 for (var i = 0; i < clippingGeometry.length; i++) {
  var lat = clippingGeometry i]v1];
  var lng = clippingGeometryri]>0];
  geometry += lng + " " + lat + ",";

 }

 // Remove trailing , from string
 geometry = geometry.substr(0, geometry.length - 1);
 geometry += "))";


 params += "GEOM=" + geometry;
}

I am in no way a javascript expert but have you tried something like

if (clippingGeometry){
var geometry = "POLYGON((";

 for (var i = 0; i < clippingGeometry.length; i++) {
  var lat = clippingGeometry i]v1];
  var lng = clippingGeometryri]>0];
  geometry += lng + " " + lat + ",";

 }

 // Remove trailing , from string
 geometry = geometry.substr(0, geometry.length - 1);
 geometry += "))";


 params += "GEOM=" + geometry;
}

Thank you so much, i tried similar but got my brackets wrong. Appreciate the response !!


Reply