Intersect for javascript

08-28-2014 01:31 PM
New Contributor II

hi i need examples of Intersect method in javascript

5 Replies
New Contributor II

Here is an example from ESRI server. I hope it helps. Intersect (Geometry) 

New Contributor II

hello, thank you very much for responding, I have a problem I want to insert a point on the map, that point should make Intersect a service that has a polygon maps and see that point come into polygons. want to know a little more of the Intersect method

Regular Contributor

Hi Ana,

if you have got your polygon and point geometry object, then you can use contains on your polygon geometry.

polygon-amd | API Reference | ArcGIS API for JavaScript

New Contributor II

I can suggest two ways one of the is if you have a polygon as a geometry in the map then you may use polygon.contains(point) as long as they are in the same spatial reference, it's a synchronous method, which means process wait until it completes. The other option is GeometryService.instersect([polygon], point, successFunction, errorFunction)

GeometryService allows you to intersect multiple geometries to a geometry in the same spatial reference. This method is a asynchronous method, which means the process will be done in the background. Once it completes calls the successFunction, if there is no error. I'm assuming the map service's geometry type is polygon. So another option I can think is Identify the point in the polygon. If it returns with results then the point intersects to the polygon.

var identify = new IdentifyTask(url);

identifyParams.geometry = evt.mapPoint;

identifyParams.mapExtent = map.extent;
.execute(identifyParams, successFunction, errorFunction);

I hope it helps.

New Contributor II

yes, I'll do it with GeometryService, but my polygons are a map service I want to know how to put this in my function I have something like gs.intersect

  var gs = new esri.tasks.GeometryService("");

gs.intersect (mispuntos, my service, onCompleteFunc, onErrorFunc);

mispuntos = user are assigned

my service = is a mapping service that is defined.