Maps 是否支持geojson循环?

Maps 是否支持geojson循环?,maps,d3.js,leaflet,geojson,Maps,D3.js,Leaflet,Geojson,当我查看GeoJson的规范时,我发现圆是受支持的: 但是,当我在geojsonlint()中尝试代码时,它会给我一个错误 输入: { "type": "Circle", "coordinates": [4.884, 52.353], "radius": 200 } 给出: "Circle" is not a valid GeoJSON type. 我想通过使用d3在地图上显示不同的兴趣地点,并对其产生一定的影响。它需要GeoJson作为输入,但确实GeoJson不支持圆 当我查看Ge

当我查看GeoJson的规范时,我发现圆是受支持的:

但是,当我在geojsonlint()中尝试代码时,它会给我一个错误

输入:

{ 
"type": "Circle",
"coordinates": [4.884, 52.353],
"radius": 200
}
给出:

"Circle" is not a valid GeoJSON type. 
我想通过使用d3在地图上显示不同的兴趣地点,并对其产生一定的影响。它需要GeoJson作为输入,但确实GeoJson不支持圆

当我查看GeoJson的规范时,我发现圆圈是受支持的


他们不是。看来你找到了一些假的或不正确的规格。请访问geojson.org查找,这里没有关于圆圈的内容。

geojson不支持圆圈, 但可以使用LineString模拟圆

使用LineString geiometry对象

"geometry": {
        "type": "LineString",
        "coordinates": [
                    [center_X, center_y],
                    [center_X, center_y]
                ]
      }
then set the dynamic style use radius as the strokeweight
function featureStyle(feature){
    return {
      strokeWeight: radius,
    };
  }
它看起来像地图上的一个圆。

如图所示,GeoJson规范中不支持圆

A circle... some code I use for making a circle for an OpenStreetMap

-- x is decimal latitude
-- y is decimal longitude
-- r is radius --  .00010 is about 40m in OSM (3 about 50km)

-- Adjust for map latitude distortion further north or south

x = math.log(math.tan((90 + x) * math.pi/360)) / (math.pi/180)

-- For loop to gather all the points of circle here 1 to 360
-- can also use the for loop to make some other interesting shapes

for i = 1, 360 do
    angle = i * math.pi / 180
    ptx = x + r * math.cos( angle )
    pty = y + r * math.sin( angle )

-- readjust latitude for map distortion

    ptx = 180/math.pi * (2 * math.atan(math.exp( ptx * math.pi/180)) - math.pi/2 )

-- Build an array of positions for GeoJSON - formatted lat and long

    data[i] = '[' .. string.format("%.6f",pty) .. ","
    data[i] = data[i] .. string.format("%.6f",ptx) .. ']'

-- End of for loop
end

-- Cycle through the data array with another for loop to build the
   coordinates (put in brackets and commas etc. for the actual
   GeoJSON coordinates string. Add data[1] to the end to close
   the polygon (circle). A circle.

-- If you want a solid circle then use fill and a hex color
-- If you want a LineString just make fill invisible or #ffffff
      Include the stroke-width and stroke-color parameters as well.
-- If latitude is greater than 89.5 or less than -89.5 you may wish
   to cut off the circle by drawing a line at polar regions by using
   those latitudes.
-- I use this simply for several circles and not for hundreds of them.

Cheers!
-- 
然而,大多数地图实现将允许您创建圆,但如果这对您不起作用(例如,您需要将其存储在数据库中并进行查询),解决方案是创建一个大致近似于圆的多边形(想象一个具有32条以上边的多边形)

我写了一封信。您可以这样使用它:

const circleToPolygon = require('circle-to-polygon');

const coordinates = [-27.4575887, -58.99029]; //[lon, lat]
const radius = 100;                           // in meters
const numberOfEdges = 32;                     //optional that defaults to 32

let polygon = circleToPolygon(coordinates, radius, numberOfEdges);

为了阐明为什么不支持圆,它与地球的曲率有关。因为地球不是一个完美的球体,如果你在上面画一个圆形,它也不会是一个完美的圆。但是,上述解决方案适用于大多数不需要临界精度的情况。

您可以覆盖
L.Circle.toGeoJSON()
以添加额外的属性来指示该点应表示为圆:虽然它不是标准的,但它提供了要表示为圆的元数据。啊,是的,但这将通过使用传单api来解决。这会起作用,但您不会使用geojson本身,而是使用传单提供的功能。D3将提供一个类似的解决方案,它独立于您使用的映射库