颜色交叉单张圆圈

如何解决颜色交叉单张圆圈

我有一个关于传单/folium 的问题。我在地图上有多个圆圈。 所有这些圆圈确实有一些重叠。 Wat我想要做的是用不同的颜色绘制一条线/多边形,所有圆圈都在这里相遇(相交)。

这是我想要实现的example。蓝线是交点,需要不同的颜色。这在大叶或纯传单中可能吗?如果是这样,我该怎么做?

解决方法

您可以为此使用 turfjs 库和 turf.intersect 方法

/* eslint-disable no-undef */
/**
 * intersection with turfjs
 */

// config map
let config = {
  minZoom: 7,maxZomm: 18,};
// magnification with which the map will start
const zoom = 18;
// co-ordinates
const lat = 52.22977;
const lng = 21.01178;

// calling map
const map = L.map('map',config).setView([lat,lng],zoom);

// Used to load and display tile layers on the map
// Most tile servers require attribution,which you can set under `Layer`
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',{
  attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',}).addTo(map);

// three coordinate
const centers = [{
    lat: 52.22990558765487,lng: 21.01168513298035
  },{
    lat: 52.22962958994604,lng: 21.011593937873844
  },{
    lat: 52.2297445891999,lng: 21.012012362480167
  }
]

// turf.circle option
const options = {
  steps: 64,units: 'meters',options: {}
}

// circle radius
const radius = 30;

// array polygons
let polygons = [];

// set marker,add 
centers.map(({
  lat,lng
}) => {
  const polygon = turf.circle([lng,lat],radius,options);

  // add cirkle polygon to map
  L.geoJSON(polygon,{
    color: "red",weight: 2
  }).addTo(map);

  // add object to array
  polygons.push(polygon);
})

// get intersection
const intersection = turf.intersect(...polygons);

// style intersection
const intersectionColor = {
  color: "yellow",weight: 2,opacity: 1,fillColor: "yellow",fillOpacity: 0.7
};

// adding an intersection to the map
// and styling to this element
L.geoJSON(intersection,{
  style: intersectionColor
}).addTo(map);
*,:after,:before {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html {
  height: 100%;
}

body,html,#map {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@5/turf.min.js"></script>

<div id="map"></div>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?
Java在半透明框架/面板/组件上重新绘画。
Java“ Class.forName()”和“ Class.forName()。newInstance()”之间有什么区别?
在此环境中不提供编译器。也许是在JRE而不是JDK上运行?
Java用相同的方法在一个类中实现两个接口。哪种接口方法被覆盖?
Java 什么是Runtime.getRuntime()。totalMemory()和freeMemory()?
java.library.path中的java.lang.UnsatisfiedLinkError否*****。dll
JavaFX“位置是必需的。” 即使在同一包装中
Java 导入两个具有相同名称的类。怎么处理?
Java 是否应该在HttpServletResponse.getOutputStream()/。getWriter()上调用.close()?
Java RegEx元字符(。)和普通点?