我尝试用OpenLayers3和GeoJson在javascript中生成一个choropleth映射。
我想使用我的GeoJson的属性来制作这个地图。
例如,如果我有一个具有属性["name"='1']的城市和一个具有属性["name"='2']的城市,那么我想要'1‘的蓝色和'2’的红色。
我在互联网上发现了如何用OpenLayers2制作这张地图(例如,用OL2制作choropleth地图),但我没有在OL3中找到等价之处。OL2的代码如下所示:
var subteStyleMap = new OpenLa
如何将onHover处理程序添加到GEOJSON组件中?我还想在每个小节中添加一个onClick处理程序(就像国家是一个国家的子部分一样)。单击该分段的地图时,应放大该分段的地图,并移除所有其他内容。
我的当前代码
import React from 'react'
import { MapContainer, TileLayer, Marker, Popup, GeoJSON } from 'react-leaflet'
import country from '../shapefiles/country.json';
import state
大家好,我使用openlayer开发web地图。
我使用geojson,代码来自:
这是代码:
<script type="text/javascript">
// Start position for the map (hardcoded here for simplicity)
var lat=50.90685
var lon=-1.4029
var zoom=12
var map; //complex object of type OpenLayers.Map
//Initialise the 'map' object
$(funct
我的代码显示了来自GeoJSON的标记,当我放大到10级时,它加载了GeoJSON文件,但是我如何避免重新输出相同的标记?有没有办法检查在特定的地方是否已经存在一个标记?代码
map.events.register("zoomend", null, function(){
if(map.zoom == 10)
{
var bounds = map.getExtent();
console.log(bounds);
var ne = new OpenLayers.LonLat(bounds.right,bo
我有一个GPX轨道(起点==终点)转换为GeoJSON。
我现在想要在地图上显示这个轨道,只有通过跟踪封闭的地图显示。其余的应该是白色的。
到目前为止,我有以下几点:
<script type="text/javascript">
function init() {
map = new OpenLayers.Map("basicMap");
var mapnik = new OpenLayers.Layer.OSM();
var fromProjection = new OpenLayers.Projec
我必须用OpenLayers来画几条线。线要素编码为GeoJSON格式。我的代码对于硬编码的GeoJSON特性来说是可以的。但是,如果我将这些特性放在单独的文件中并尝试加载它。它就是不起作用。我不知道加载外部GeoJSON文件有什么问题。我已经给了两个代码。
代码1:
// This code is ok with hard coded GeoJSON features
map.addControl(new OpenLayers.Control.LayerSwitcher());
vectorLayer = new OpenLayers.Layer.Vector(
我能够在加载Point/MultiPoint Geojson时更改图标的src,这样:
that.geojsonLayers[index] = new that.openlayers.ol.layer.Vector({
source: new that.openlayers.ol.source.Vector({
format: new that.openlayers.ol.format.GeoJSON(),
url: url
}),
style: new that.openlayers.ol.style.
我想使用openlayers.vector从json检索一些信息,但条件是:例如(如果"type"="etat5")检索url和名称
var geojson_etat7 = new OpenLayers.Layer.Vector("etat7", {
styleMap: new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
externalGraphic:
是否有一种方法可以在开始层中读取geojson并转换为WKT格式,我的问题是,当我将多个geojson添加为向量层时,它们不作为一个层出现,请告诉我如何将多个geojson显示为单个向量层的一部分,我的代码是
for (var i = 0; i < content.GeoJsonFiles.length; i++) {
//color = content.Settings.BreakStyles[totalcolor].Color;
//totalcolor++;
var id = content.GeoJsonFiles[i];
// alert(con
这应该很容易,但是当我将该层作为geojson 加载时,特征向量是空的。
var geojson1 = new OpenLayers.Layer.GML('layer_name', '/layer_path/file_name.geojson', {
projection: new OpenLayers.Projection('EPSG:4326'),
format: OpenLayers.Format.GeoJSON});
console.log(geojson1.features.length); // the result
我正在使用我们的本地服务器生成地图,但我得到的形状数据只是数组。我使用JavaScript将其转换为geoJSON,但是我如何告诉OpenLayers使用这个obj而不是URL呢?文档不完整,谷歌没有给我提供答案。
我现在要说的是:
var marketProtocal = new OpenLayers.Protocol.HTTP({
url: 'json/lte_shapes.json',
format: new OpenLayers.Format.GeoJSON()
});
容器看起来类似于:
var geoObj = {};
$.getJSON("/
我正在使用OpenLayers,并加载了几个GEOJson文件,它们工作得很好。现在,我希望能够选择GEOJson文件的各个组件。例如,当我激活悬停选择时,如果我有一个以上的特征(几个多边形),什么都不会发生。
我在这个示例中添加了悬停选择器
实际上,我可以独立拖动元素,但不能选择它们。我想这是因为我使用的投影。有什么办法解决这个问题吗?
干杯!
function init(){
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: ne
我在显示从django服务器到openlayers上的一个矢量层的功能时遇到了问题,我已经参考了这些文章:
但还是不能表现出来。
下面是javascript代码块:
function init(){
var map = new OpenLayers.Map('map', {
projection: new OpenLayers.Projection("EPSG:3857"),
units: "km",
maxResolution: 156543.0339,
displayProj
在Vuejs项目中,我正在处理一个openlayers映射,以添加一个带有本地geojson和gpx文件源的向量层,但是向量层无法显示。我在Vue.js之外进行了测试,我也遇到了同样的问题。
语音编码:
// classes required to display the map
import Map from 'ol/Map'
import View from 'ol/View'
import TileLayer from 'ol/layer/Tile'
import OSM from 'ol/source/OSM'
// F
嗯,我想要一个很好的弹出当一个悬停,但我也希望向量可选。如果我跳过悬停部分,它就像是在施展魅力,但除此之外:/是不是我错过了什么?
vectors.removeAllFeatures();
var geojson_format = new OpenLayers.Format.GeoJSON();
vectors.addFeatures(geojson_format.read(data));
var selectCtrl = new OpenLayers.Control.SelectFeature(vectors,
{
clickout: true
});
map.addControl(