Answer the question
In order to leave comments, you need to log in
Yandex.Maps, polygon intersection: how?
There is the following code jsbin.com/feqal/1/edit
In short, there are 2 polygons, they are black in themselves, but if they intersect, then they should turn red (or at least one of them).
I use ymaps.geoQuery searchIntersect, the question is: if the edges of a polygon lie on top of each other (i.e., the same vertices), the API considers that the polygons intersect. Is it possible to somehow consider such a case as non-intersection?
Thank you very much.
var polyOptions = {
fillColor:'#000000',
strokeColor:'#000000',
strokeWidth: 2,
fillOpacity: 0.3
};
var bounds1 = [
[
[55.71661243639541, 37.45460571289062],
[55.82344443031646, 37.542496337890604],
[55.691797789925474, 37.59330810546872]
], []
];
var bounds2 = [
[
[55.82344443031646, 37.542496337890604],
[55.691797789925474, 37.59330810546872],
[55.701880648597864, 37.771835937499986],
[55.81261980047947, 37.78007568359372]
], []
];
var polygon1;
var polygon2;
var map;
ymaps.ready(init);
function init () {
map = new ymaps.Map('map', {
center:[55.76, 37.64],
zoom:10
});
map.events.add(['click'], function(e){
console.log(e.get('coords'));
});
polygon1 = new ymaps.Polygon(bounds1, {}, polyOptions);
polygon2 = new ymaps.Polygon(bounds2, {}, polyOptions);
map.geoObjects.add(polygon1);
map.geoObjects.add(polygon2);
objects = ymaps.geoQuery(polygon1);
var objectsInsideCircle = objects.searchIntersect(polygon2);
objectsInsideCircle.setOptions('fillColor', '#FF0000');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question