我必须用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(
我在一个表中有许多空间实体,其中有一个名为Boundaries的geometry字段。我想生成一个包含简化形状/几何图形的GeoJson文件。
这是我的第一次尝试:
var entities = await db.Entities.ToListAsync();
dynamic geoJson = new ExpandoObject();
geoJson.type = "FeatureCollection";
var features = new List<dynamic>();
foreach (var entity in entities)
{
//
我已经在我的地图中上传了一个包含openlayers 3的geojson文件。geojson文件是一个包含5个LineString类型的要素的FeatureCollection。如何对每个特征进行不同的着色以区分我的路径?如果我将颜色添加到geojson文件的样式中,这将不会被读取,如果我将颜色添加到笔划中,所有特征都将以单一颜色着色。
下面我将添加代码。
谢谢。
var vector = new ol.layer.Vector({
source: new ol.source.Vector({
format: new ol.format.
我遇到了一个问题,我的LineString没有显示在地图上,控制台也没有给出任何错误。
我相信我的代码是正确的,但当涉及到OpenLayers时,我不是那么聪明,我可能是错的。
这就是我将矢量图层添加到地图的方法
var vectorLayer = new ol.layer.Vector({
name: 'trailLayer',
type: "Vector",
source: new ol.source.Vector({ format: new ol.format.GeoJSON({ featureProjection:
我很困惑如何在我的特性中添加样式,这个特性由一个LineString组成,它位于一个向量中。我是将样式添加到LineString还是向量?我想改变颜色和大小的线,并可能使线不透明,如果可能的话。
mapObject = new OpenLayers.Layer.Vector("Vector");
var p1 = new OpenLayers.Geometry.Point(mapObjectTopLeftLon, mapObjectTopLeftLat);
var p2 = new OpenLayers.Geometry.Point(mapObjectTopRightLon,
大家好,我使用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
我有一个GPX轨道(起点==终点)转换为GeoJSON。
我现在想要在地图上显示这个轨道,只有通过跟踪封闭的地图显示。其余的应该是白色的。
到目前为止,我有以下几点:
<script type="text/javascript">
function init() {
map = new OpenLayers.Map("basicMap");
var mapnik = new OpenLayers.Layer.OSM();
var fromProjection = new OpenLayers.Projec
是否有一种方法可以在开始层中读取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
我想使用openlayers.vector从json检索一些信息,但条件是:例如(如果"type"="etat5")检索url和名称
var geojson_etat7 = new OpenLayers.Layer.Vector("etat7", {
styleMap: new OpenLayers.StyleMap({
"default": new OpenLayers.Style({
externalGraphic:
我正在尝试设计LineString的样式,但它似乎不起作用。这是我的代码:
function connectStationFeatures(feat1, feat2){
var lineLayer = getLinesLayer();
var point1 = feat1.geometry;
var point2 = feat2.geometry;
var style = new OpenLayers.StyleMap({
'fillColor':"#FF8C00",
'strokeWidt
我能够在加载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.
我尝试用OpenLayers3和GeoJson在javascript中生成一个choropleth映射。
我想使用我的GeoJson的属性来制作这个地图。
例如,如果我有一个具有属性["name"='1']的城市和一个具有属性["name"='2']的城市,那么我想要'1‘的蓝色和'2’的红色。
我在互联网上发现了如何用OpenLayers2制作这张地图(例如,用OL2制作choropleth地图),但我没有在OL3中找到等价之处。OL2的代码如下所示:
var subteStyleMap = new OpenLa
我想向添加一个名为"getLatLngPath“的函数,它将获取一个geojson对象,并为geojson中的任何LineString或MultiLineString功能生成一个latlng数组。很简单。
因为我没有覆盖任何代码,而且它是一个静态函数,所以我的想法是使用方法,希望能够以L.GeoJSON.getLatLngPath(...)的形式访问该函数。代码:
L.GeoJSON.include({
/*
* Returns a single array containing all the latlngs from each LineString feature
我是通过依次从多个OpenLayer特性加载数组multipointCoords来填充GeoJSON 3特性。每次加载GeoJSON特性时,我都重用以下函数:
function makeLineString(multipointCoords) {
var trackSource = new ol.source.Vector();
var lineString = new ol.geom.LineString([ // create a linestring geometry from the GeoJSON data for the tracks
我使用openlayers 5和angular6。我得到了向量层的一些特性,并将它们放在数组广告中,我尝试动态地创建一个LineString。
到目前为止,这是我的代码
import * as Extent from 'ol/extent.js';
import Geometry from 'ol/geom/Geometry.js';
import LineString from 'ol/geom/LineString.js';
extent: Extent;
linestring: LineString;
geometry: Ge
我在显示从django服务器到openlayers上的一个矢量层的功能时遇到了问题,我已经参考了这些文章:
但还是不能表现出来。
下面是javascript代码块:
function init(){
var map = new OpenLayers.Map('map', {
projection: new OpenLayers.Projection("EPSG:3857"),
units: "km",
maxResolution: 156543.0339,
displayProj