我想将geojson中的附加信息绑定到传单标记弹出窗口.我从传单文档中查找了一些内容,但它不起作用.
var map = L.map('map').setView([51.9, 7.6], 11);
L.tileLayer('http://{s}.tile.cloudmade.com/5e4495ff4b0d454eb0443225198b7e6c/997/256/{z}/{x}/{y}.png', {
maxZoom: 16
}).addTo(map);
var polygon = {
"type": "Feature",
"properties": {
"name":"City BoundingBox",
"style": {
"color": "#004070",
"weight": 4,
"opacity": 1
}
},
"geometry": {
"type": "Polygon",
"coordinates": [[
[7.5,52.05],
[7.7,51.92],
[7.6,51.84],
[7.4,51.94],
[7.5,52.05]
]]
}
};
var myLayer = L.geoJson().addTo(map);
//myLayer.addData(polygon);
var popup = L.popup();
function onMapClick(e) {
popup
.setLatLng(e.latlng)
.setContent("You clicked the map at " + e.latlng.toString())
.openOn(map);
}
map.on('click', onMapClick);
<?php
$mdjson = file_get_contents("http://xxx/ows?service=WFS&version=1.0.0&outputFormat=JSON&request=GetFeature&typeName=xx:yy&maxFeatures=50");
echo "var geojsonMD = …Run Code Online (Sandbox Code Playgroud) 我有一张地图使用geoJSON文件来绘制国家.然后我想画一个以每个国家为中心的圆圈.但对于有几个边界地区的国家(美国有大陆,夏威夷,阿拉斯加),我希望这个圈子位于最大的边界地区.我试图通过比较不同边界区域的区域来做到这一点,但由于我无法理解的原因它无法正常工作.
以下是geoJSON的示例,显示了澳大利亚如何拥有多个边界区域:
{"type":"Feature","properties":{"name":"Australia"},"geometry":{"type":"MultiPolygon","coordinates":[[[[145.397978,-40.792549],[146.364121,-41.137695],[146.908584,-41.000546],[147.689259,-40.808258],[148.289068,-40.875438],[148.359865,-42.062445],[148.017301,-42.407024],[147.914052,-43.211522],[147.564564,-42.937689],[146.870343,-43.634597],[146.663327,-43.580854],[146.048378,-43.549745],[145.43193,-42.693776],[145.29509,-42.03361],[144.718071,-41.162552],[144.743755,-40.703975],[145.397978,-40.792549]]],[[[143.561811,-13.763656],[143.922099,-14.548311],[144.563714,-14.171176],[144.894908,-14.594458],[145.374724,-14.984976],[145.271991,-15.428205],[145.48526,-16.285672],[145.637033,-16.784918],[145.888904,-16.906926],[146.160309,-17.761655],[146.063674,-18.280073],[146.387478,-18.958274],[147.471082,-19.480723],[148.177602,-19.955939],[148.848414,-20.39121],[148.717465,-20.633469],[149.28942,-21.260511],[149.678337,-22.342512],[150.077382,-22.122784],[150.482939,-22.556142],[150.727265,-22.402405],[150.899554,-23.462237],[151.609175,-24.076256],[152.07354,-24.457887],[152.855197,-25.267501],[153.136162,-26.071173],[153.161949,-26.641319],[153.092909,-27.2603],[153.569469,-28.110067],[153.512108,-28.995077],[153.339095,-29.458202],[153.069241,-30.35024],[153.089602,-30.923642],[152.891578,-31.640446],[152.450002,-32.550003],[151.709117,-33.041342],[151.343972,-33.816023],[151.010555,-34.31036],[150.714139,-35.17346],[150.32822,-35.671879],[150.075212,-36.420206],[149.946124,-37.109052],[149.997284,-37.425261],[149.423882,-37.772681],[148.304622,-37.809061],[147.381733,-38.219217],[146.922123,-38.606532],[146.317922,-39.035757],[145.489652,-38.593768],[144.876976,-38.417448],[145.032212,-37.896188],[144.485682,-38.085324],[143.609974,-38.809465],[142.745427,-38.538268],[142.17833,-38.380034],[141.606582,-38.308514],[140.638579,-38.019333],[139.992158,-37.402936],[139.806588,-36.643603],[139.574148,-36.138362],[139.082808,-35.732754],[138.120748,-35.612296],[138.449462,-35.127261],[138.207564,-34.384723],[137.71917,-35.076825],[136.829406,-35.260535],[137.352371,-34.707339],[137.503886,-34.130268],[137.890116,-33.640479],[137.810328,-32.900007],[136.996837,-33.752771],[136.372069,-34.094766],[135.989043,-34.890118],[135.208213,-34.47867],[135.239218,-33.947953],[134.613417,-33.222778],[134.085904,-32.848072],[134.273903,-32.617234],[132.990777,-32.011224],[132.288081,-31.982647],[131.326331,-31.495803],[129.535794,-31.590423],[128.240938,-31.948489],[127.102867,-32.282267],[126.148714,-32.215966],[125.088623,-32.728751],[124.221648,-32.959487],[124.028947,-33.483847],[123.659667,-33.890179],[122.811036,-33.914467],[122.183064,-34.003402],[121.299191,-33.821036],[120.580268,-33.930177],[119.893695,-33.976065],[119.298899,-34.509366],[119.007341,-34.464149],[118.505718,-34.746819],[118.024972,-35.064733],[117.295507,-35.025459],[116.625109,-35.025097],[115.564347,-34.386428],[115.026809,-34.196517],[115.048616,-33.623425],[115.545123,-33.487258],[115.714674,-33.259572],[115.679379,-32.900369],[115.801645,-32.205062],[115.689611,-31.612437],[115.160909,-30.601594],[114.997043,-30.030725],[115.040038,-29.461095],[114.641974,-28.810231],[114.616498,-28.516399],[114.173579,-28.118077],[114.048884,-27.334765],[113.477498,-26.543134],[113.338953,-26.116545],[113.778358,-26.549025],[113.440962,-25.621278],[113.936901,-25.911235],[114.232852,-26.298446],[114.216161,-25.786281],[113.721255,-24.998939],[113.625344,-24.683971],[113.393523,-24.384764],[113.502044,-23.80635],[113.706993,-23.560215],[113.843418,-23.059987],[113.736552,-22.475475],[114.149756,-21.755881],[114.225307,-22.517488],[114.647762,-21.82952],[115.460167,-21.495173],[115.947373,-21.068688],[116.711615,-20.701682],[117.166316,-20.623599],[117.441545,-20.746899],[118.229559,-20.374208],[118.836085,-20.263311],[118.987807,-20.044203],[119.252494,-19.952942],[119.805225,-19.976506],[120.85622,-19.683708],[121.399856,-19.239756],[121.655138,-18.705318],[122.241665,-18.197649],[122.286624,-17.798603],[122.312772,-17.254967],[123.012574,-16.4052],[123.433789,-17.268558],[123.859345,-17.069035],[123.503242,-16.596506],[123.817073,-16.111316],[124.258287,-16.327944],[124.379726,-15.56706],[124.926153,-15.0751],[125.167275,-14.680396],[125.670087,-14.51007],[125.685796,-14.230656],[126.125149,-14.347341],[126.142823,-14.095987],[126.582589,-13.952791],[127.065867,-13.817968],[127.804633,-14.276906],[128.35969,-14.86917],[128.985543,-14.875991],[129.621473,-14.969784],[129.4096,-14.42067],[129.888641,-13.618703],[130.339466,-13.357376],[130.183506,-13.10752],[130.617795,-12.536392],[131.223495,-12.183649],[131.735091,-12.302453],[132.575298,-12.114041],[132.557212,-11.603012],[131.824698,-11.273782],[132.357224,-11.128519],[133.019561,-11.376411],[133.550846,-11.786515],[134.393068,-12.042365],[134.678632,-11.941183],[135.298491,-12.248606],[135.882693,-11.962267],[136.258381,-12.049342],[136.492475,-11.857209],[136.95162,-12.351959],[136.685125,-12.887223],[136.305407,-13.29123],[135.961758,-13.324509],[136.077617,-13.724278],[135.783836,-14.223989],[135.428664,-14.715432],[135.500184,-14.997741],[136.295175,-15.550265],[137.06536,-15.870762],[137.580471,-16.215082],[138.303217,-16.807604],[138.585164,-16.806622],[139.108543,-17.062679],[139.260575,-17.371601],[140.215245,-17.710805],[140.875463,-17.369069],[141.07111,-16.832047],[141.274095,-16.38887],[141.398222,-15.840532],[141.702183,-15.044921],[141.56338,-14.561333],[141.63552,-14.270395],[141.519869,-13.698078],[141.65092,-12.944688],[141.842691,-12.741548],[141.68699,-12.407614],[141.928629,-11.877466],[142.118488,-11.328042],[142.143706,-11.042737],[142.51526,-10.668186],[142.79731,-11.157355],[142.866763,-11.784707],[143.115947,-11.90563],[143.158632,-12.325656],[143.522124,-12.834358],[143.597158,-13.400422],[143.561811,-13.763656]]]]},"id":"AUS"},
Run Code Online (Sandbox Code Playgroud)
这是我尝试比较不同边界区域的代码.在那个if声明中,我试图弄清楚这个国家是否有多个边界区域(似乎有效),然后在for区块中挑选最大的一个.
问题:我得到的"区域"值都是0,coords并且总是从第一个边界区域中选择,而不是最大的.
function calculateCountryCenter(country) {
var coords;
//Check if the country has more than one bounding region.
if (country.geometry.coordinates.length > 1) {
coords = country.geometry.coordinates[0][0];
var regionArea = path.area(country.geometry.coordinates[0]);
for (var i=0; i<country.geometry.coordinates.length; i++) {
if (path.area(country.geometry.coordinates[i]) > regionArea) {
coords = country.geometry.coordinates[i][0];
}
}
} else {
coords = country.geometry.coordinates[0];
}
var averageCoords = [0,0];
coords.forEach(function(coord) {
averageCoords[0] += coord[0]
averageCoords[1] += coord[1]
});
averageCoords[0] = averageCoords[0] / coords.length
averageCoords[1] …Run Code Online (Sandbox Code Playgroud) 我第一次使用GeoDjango并且在添加PointField模型时遇到了麻烦.这是我的型号代码:
from django.db import models
from django.contrib.gis.geos import Point
from django.contrib.gis.db import models
class Crime(models.Model):
Category = models.CharField(max_length=50)
Description = models.CharField(max_length=150)
District =models.CharField(max_length=50)
Incident = models.IntegerField(default=0)
Date = models.DateTimeField(max_length=150,default="")
Location = models.PointField()
Run Code Online (Sandbox Code Playgroud)
当我尝试创建迁移时,我收到错误:
ValueError:不能将类型为float的对象用于几何查找参数.
当我尝试在Python shell中创建犯罪对象并保存它时,我得到错误:
django.core.exceptions.ValidationError
我一直在对此进行故障排除已有一段时间了.我在实际的gis库代码中放了一个调试器,发现在ValueError抛出之前,它试图将数字35.0作为几何对象处理.
我想知道这个错误是否与需要在Django中设置默认值或者我的数据库连接可能有什么问题有关?
我试图从这里使用真棒PHP-Database-GeoJSON库获取GeoJSON线串格式https://github.com/bmcbride/PHP-Database-GeoJSON但是现在没有任何运气
我成功地使用该库从MySQL表调用简单点,但是使用线和多边形,故事有点不同.
首先,我创建了几何字段表,如下所示:
-- phpMyAdmin SQL Dump
-- version 4.4.6
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Jan 20, 2016 at 10:12 PM
-- Server version: 5.6.24
-- PHP Version: 5.6.8
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `web_gis`
--
-- --------------------------------------------------------
--
-- Table structure for table `wkt_linija`
--
DROP TABLE IF EXISTS `wkt_linija`; …Run Code Online (Sandbox Code Playgroud) 我有一个多边形的功能集合,我必须首先在临时文件中写入然后加载它geopandas.GeoDataFrame.from_file(tmp_json_file),有没有办法不写临时文件,只是GeoDataFrame从GeoJSON对象创建?
我希望某些图层始终位于其他图层之上,无论它们以何种顺序添加到地图中.我知道bringToFront(),但它不符合我的要求.我想根据属性动态设置zIndex.
Leaflet有方法setZIndex(),但这显然不适用于geoJson层:https://jsfiddle.net/jw2srhwn/
有任何想法吗?
我有一个@Entity具有type属性的模型com.vividsolutions.jts.geom.Point。当我尝试在中呈现此模型时,出现@RestController了递归异常。
(StackOverflowError); nested exception is
com.fasterxml.jackson.databind.JsonMappingException: Infinite
recursion (StackOverflowError) (through reference chain:
com.vividsolutions.jts.geom.Point[\"envelope\"]-
>com.vividsolutions.jts.geom.Point[\"envelope\"]....
Run Code Online (Sandbox Code Playgroud)
实体看起来像这样(为简洁起见简称):
@Entity
@Data
public class MyEntity{
// ...
@Column(columnDefinition = "geometry")
private Point location;
// ...
}
Run Code Online (Sandbox Code Playgroud)
经过研究,我发现这是因为杰克逊默认情况下无法反序列化GeoJson。添加此库应该可以解决此问题:https : //github.com/bedatadriven/jackson-datatype-jts。
我现在不确定如何在Spring Boot的对象映射器中包含此模块。根据引导中的文档,我尝试通过@Configuration以下两种方式将其添加到中:
@Bean
public Jackson2ObjectMapperBuilder jacksonBuilder() {
Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.modulesToInstall(new JtsModule());
return builder;
}
Run Code Online (Sandbox Code Playgroud)
和
@Bean
public JtsModule jtsModule(){
return new JtsModule();
}
Run Code Online (Sandbox Code Playgroud)
两者都没有删除异常。不好意思,如果这是重复的,但是我能找到的就是自定义ObjectMapper,在我对文档的理解中,这不是“弹簧启动方式”。
作为一种变通方法,我@JsonIgnore荷兰国际集团的Point和定制的getter和setter一个不存在协调对象,......但它不是我想保持它的方式。
addGeoJson 无法在谷歌地图中为我的文件工作
请检查下面我在 javascript 中使用的代码
//create the map
map = new google.maps.Map(document.getElementById('map-canvas'), {
zoom: 6,
center: {lat:49.79, lng: -8.82}
});
// Load GeoJSON.
var promise = $.getJSON("Sensitive_Areas_Nitrates_Rivers.json"); //same as map.data.loadGeoJson();
promise.then(function(data){
cachedGeoJson = data; //save the geojson in case we want to update its values
console.log(cachedGeoJson);
map.data.addGeoJson(cachedGeoJson,{idPropertyName:"id"});
});
Run Code Online (Sandbox Code Playgroud)
我已经从这里下载了这个文件
你可以查看我的 JSON 文件 Sensitive_Areas_Nitrates_Rivers.json
此外,您可以 使用多边形检查此链接
我使用了以下 JSON 格式,因此您可以检查它
{ "type": "FeatureCollection", "crs": { "type": "name", "properties": { "name": "EPSG:27700" } }, "features": [ { "type": "特征", "id": …
我是 MapBox GL Js 的新手,我想通过 https 调用一个大的 GeoJSON 文件并将其显示到地图上。我认为调用矢量平铺是最好的方法,我发现一些教程展示了如何将 GeoJSON 数据转换为矢量平铺,但在服务器端或将其上传到 MapBox 样式,但我的 GeoJSON 文件经常更改。所以我找到了这个解决方案是一个名为 geojson-vt 的新 JavaScript 库,描述了如何将巨大的 GeoJSON 文件快速转换为矢量切片(客户端),这似乎是我正在寻找的,但是! ,如何将其集成到MapBox GL JS中以调用图层?
阻止如何使用 Mapbox GL JS 添加图层,结果如下:vartileIndex = geojsonvt(MyGeoJSON); vartile =tileIndex.getTile(z,x,y);
...或者我只是没有明白!请有人帮助或可以为我的问题提出其他解决方案。
我正在努力根据它们的几何形状(在显示一些 GeoJSON 数据的上下文中)自动推断不同类型项目的类型。
我使用的是通用类型,因此我没有设法设置自定义类型保护,因为它可以让我区分“个人”项目和“聚合”,但不能区分不同类型的“个人”项目。
基本上,我需要推理级别:
我创建了一个简化示例,在我的真实应用程序中,我有 4 种不同类型的项目,它们可能具有不同的几何形状。
这是一个 TypeScript playground,代码如下:
type A = {type: "A", a: string}
type B = {type: "B", b: string}
type C = {type: "C", c: string}
type Geometries = A | B | C
type IndividualFeature<G extends A | B = A | B> = { geometry: G, indivAttribute: string}
type AggregateFeature = { geometry: C, aggAttribute: string}
type DisplayableFeature = IndividualFeature | AggregateFeature
const display = (feature: DisplayableFeature) => { …Run Code Online (Sandbox Code Playgroud) geojson ×10
javascript ×3
leaflet ×2
d3.js ×1
geodjango ×1
geopandas ×1
gis ×1
google-maps ×1
jackson ×1
java ×1
mapbox ×1
mapbox-gl-js ×1
mysql ×1
php ×1
postgresql ×1
python ×1
spring-boot ×1
typescript ×1
vector-tiles ×1
wkt ×1
z-index ×1