我已经成功加载了将要素集加载到的geoJSON文件中
d3.geo.path()
Run Code Online (Sandbox Code Playgroud)
我当前实现的问题是它开始缩放,使得路径是一个点,我必须每次放大.现在我知道有很多方法可以正确设置缩放级别,但我希望能够使用
d3.geo.bounds()
Run Code Online (Sandbox Code Playgroud)
鉴于以下geoJSON功能:
json.features[0]:
Object
geometry: Object
coordinates: Array[2]
0: -71.248913
1: 44.078426
length: 2
__proto__: Array[0]
type: "Point"
__proto__: Object
id: 2
type: "Feature"
__proto__: Object
Run Code Online (Sandbox Code Playgroud)
和
json.features[1]:
Object
geometry: Object
coordinates: Array[2]
0: -71.249021
1: 44.078387
length: 2
__proto__: Array[0]
type: "Point"
__proto__: Object
id: 3
type: "Feature"
__proto__: Object
Run Code Online (Sandbox Code Playgroud)
如果我执行
d3.geo.bounds(json.features)
Run Code Online (Sandbox Code Playgroud)
我得到无限的界限:
d3.geo.bounds(json.features)
[
Array[2]
0: Infinity
1: Infinity
length: 2
__proto__: Array[0]
,
Array[2]
0: -Infinity
1: -Infinity
length: 2
__proto__: Array[0]
]
Run Code Online (Sandbox Code Playgroud)
我不确定是什么问题,显然我有一个比上面更大的数据集,但我只是想了解输出.这个输出对我来说没有意义,显然缺少关于d3处理geoJSON数据的简单方法.任何帮助以获得工作的帮助都会有所帮助. …
我试图建立在mapbox集群地图,像http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html
但他们的示例使用普通的.js文件作为数据 http://www.mapbox.com/mapbox.js/assets/realworld.388.js
我可以从mapbox唯一得到的是.geojson http://api.tiles.mapbox.com/v3/thebteam.map-w9jzcznw/markers.geojson
有没有办法可以将geojson转换为js(定期)?或者从mapbox导出javascript数组?
编辑:最终将我的数据切换为CSV并找到解析器.这是有效的代码,如果有人需要它:
var url = 'https://docs.google.com/spreadsheet/pub?key=abc123';
$.get(url, function(data) {
var addressPoints = $.csv.toArrays(data);
var map = L.mapbox.map('map', 'map-abc123').setView([20.30, 18.98], 2);
var markers = new L.MarkerClusterGroup({ showCoverageOnHover: false });
for (var i = 0; i < addressPoints.length; i++) {
var a = addressPoints[i];
var title = a[2];
var marker = L.marker(new L.LatLng(a[0], a[1]), {
icon: L.mapbox.marker.icon({'marker-size': 'small', 'marker-color': 'e8168c'}),
title: title
});
marker.bindPopup(title);
markers.addLayer(marker);
}
map.addLayer(markers);
});
Run Code Online (Sandbox Code Playgroud) 我正在使用D3.js库从US Census shapefile创建地图.我正在寻找创建一个完整的美国地图,这是没有问题的,以及每个州的地图.
我的工作流程使用人口普查数据,ogr2ogr在命令行根据需要进行了更改,然后由shpescape.com转换为topojson或geojson,因为topojson模块的node.js下载错误(请参阅下面的编辑解决方案)问题).
我的问题更多的是一个实用的问题而不是其他任何问题 - 当提供此代码时(以http://bl.ocks.org/mbostock/4707858为模型):
var width = 640,
height = 500;
var projection = d3.geo.albers();
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("mt_geo.json", function(error, mt_topo) {
var states = topojson.feature(mt_topo, mt_topo.objects.states),
state = states.features.filter(function(d) { return d.id === 34; })[0];
projection
.scale(1)
.translate([0,0]);
var b = path.bounds(state),
s = .95 / Math.max ((b[1][0]-b[0][0])/width, (b[1][1]-b[0][1])/height),
t = [(width-s*(b[1][0]+b[0][0]))/2, (height-s*(b[1][1]+b[0][1]))/2];
projection
.scale(s)
.translate(t);
svg.append("path")
.datum(states)
.attr("class", "feature")
.attr("d", path);
svg.append("path")
.datum(topojson.mesh(us, …Run Code Online (Sandbox Code Playgroud) 有人能告诉我如何在Apple地图中绘制GeoJson文件作为叠加层?我想要一个完整的例子,我有多边形或多边形的形状?
如果您向我提供了用于渲染它的代码或库,那么这个文件Countries GeoJSON就足够了MKMapView
我正在尝试在mongodb中使用一些地理定位功能.使用$ near的查询查询似乎不起作用!
我目前在我的数据库中有这个对象:
{
"Username": "Deano",
"_id": {
"$oid": "533f0b722ad3a8d39b6213c3"
},
"location": {
"type": "Point",
"coordinates": [
51.50998,
-0.1337
]
}
}
Run Code Online (Sandbox Code Playgroud)
我也设置了以下索引:
{
"v": 1,
"key": {
"location": "2dsphere"
},
"ns": "heroku_app23672911.catchmerequests",
"name": "location_2dsphere",
"background": true
}
Run Code Online (Sandbox Code Playgroud)
当我运行此查询时:
db.collectionname.find({ "location" : { $near : [50.0 , -0.1330] , $maxDistance : 10000 }})
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
error: {
"$err" : "can't parse query (2dsphere): { $near: [ 50.0, -0.133 ], $maxDistance: 10000.0 }",
"code" : 16535
}
Run Code Online (Sandbox Code Playgroud)
有谁知道我哪里出错了?任何帮助将非常感激!
我尝试在Mapbox中加载geoJson数据并使用插件Leaflet.Draw对其进行编辑
这是一个例子:小提琴
var featureGroup = L.featureGroup().addTo(map);
var geojson = {
"type": "FeatureCollection",
"features": [ ........... ]
}
L.geoJson(geojson).addTo(featureGroup);
Run Code Online (Sandbox Code Playgroud)
当我点击编辑按钮时,我有一个错误:
未捕获的TypeError:无法读取未定义的属性"enable"
对象似乎是可编辑的,但我无法修改它.
在mapbox 绘图层中添加geojson对象的正确方法是什么?
我很好奇OpenLayers3中动画功能的可能性.
我非常了解这里提供的示例 http://openlayers.org/en/v3.0.0/examples/animation.html和 https://gis.stackexchange.com/questions/26546/openlayers-animation-examples -and-算法
但是,OL3的官方示例并不完全符合我的需求.
假设我有一个图层(例如geojson),它有一个带有大量时间值的"时间"列.
我想实现类似滑块的功能,根据用户的操作添加/删除功能(或更改其样式).
问题是有一些API可能能够做到这一点,但它们似乎已经过时(代码示例仍在使用ol2).
您对如何使用OL3构建简单动画滑块有任何建议吗?
编辑:它不一定是适当的动画.我想到的一种可能性是每当移动滑块时都会改变图层的样式.尽管如何实现这一点仍然没有任何线索.
这张图片说明了我的想法:

编辑:我目前的方法是有一个滑块,每次移动时触发代码.我试图动态地改变图层样式,但我仍然没有得到可行的结果.
这是整个HTML文档:
<!DOCTYPE html>
<html>
<head>
<title>Top 5 Importers of Tungsten</title>
<!--Imports stylesheet from Leaflet -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.css" />
<!-- Import jQuery, a common JavaScript library providing hundreds of functions -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<style>
@font-face {
font-family: Planewalker;
src: url('https://dl.dropboxusercontent.com/s/3hn6zi8ez2vf4d7/Planewalker.ttf');
}
a:link{text-decoration: none;color:#0000FF;}
a:visited{text-decoration:none;color:#0000FF;}
a:hover{color:#990000;text-decoration:none;}
#map {
width: 1200px;
height: 600px;
border: black solid 2px;
display: block;
margin-left: auto;
margin-right: auto;
}
#map2 {
width: 1000px;
height: 550px;
border: black solid 2px;
display: block;
margin-left: auto;
margin-right: auto;
} …Run Code Online (Sandbox Code Playgroud) 如何将点作为单个要素添加到多边形?根据GeoJson规范,这被称为"GeometryCollection".
'GeometryCollection'的示例:
{ "type": "GeometryCollection",
"geometries": [
{ "type": "Point",
"coordinates": [100.0, 0.0]
},
{ "type": "LineString",
"coordinates": [ [101.0, 0.0], [102.0, 1.0] ]
}
]
}
Run Code Online (Sandbox Code Playgroud)
我尝试在多边形特征中添加一个点,但我无法在地图集地图上显示它,因为我猜它是无效的GeoJson.
任何人都知道这样做的正确方法是什么?网上没有太多的例子可供使用.
我的看法:[jsfilddle]
var myRegions = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometries": [
{
"type": "Point",
"coordinates": [
61.34765625,
48.63290858589535
]
},
{
"type": "Polygon",
"coordinates": [
[
[
59.94140624999999,
50.65294336725709
],
[
54.931640625,
50.90303283111257
],
[
51.943359375,
51.04139389812637
],
[
50.9765625,
48.19538740833338
],
[
52.55859375,
46.46813299215554 …Run Code Online (Sandbox Code Playgroud) 我有一个多边形的功能集合,我必须首先在临时文件中写入然后加载它geopandas.GeoDataFrame.from_file(tmp_json_file),有没有办法不写临时文件,只是GeoDataFrame从GeoJSON对象创建?