由于一些奇怪的原因,这个jsfiddle示例中的代码在迭代关联值数组时复制元素.输入字段正确显示3个名称,但每个名称的字段重复3次.更令人困惑的是,{{ p.name }}显示的值与ng-model="p.name"每次迭代的值不同.索引每次显示0,1和2三次.为什么每个元素会有三次迭代?
控制器:
var app=angular.module('myApp', []);
function MyCtrl($scope) {
$scope.people = [
{ name:'Tom', age:5 },
{ name:'Dick', age:6 },
{ name:'Harry', age:7 }
];
}
Run Code Online (Sandbox Code Playgroud)
HTML:
<div ng-controller="MyCtrl">
<form>
<ul>
<li ng-repeat="p in people">{{$index}}, {{$first}}, {{$middle}}, {{$last}}, {{p.name}}, {{p.age}}
<input type="text" ng-model="p.name">
</li>
</ul>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
有关此代码有什么问题的任何想法?
有人可以解释一下为什么这个传单代码可用于可视化纽约州的GeoJson数据但我无法绘制纽约市的数据.我对QGIS中的文件使用了相同的导出首选项.
我使用了以下链接中的数据:
纽约市 http://www.nyc.gov/html/dcp/html/bytes/districts_download_metadata.shtml
纽约州 http://cugir.mannlib.cornell.edu/bucketinfo.jsp?id=7865
<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<link rel="stylesheet" href="style_blank.css" />
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="sdfgsdgdfgfdsgd.js"></script>
<div id="map"></div>
<script>
var map = L.map('map',{
center: [5,28],
zoom: 3,
minZoom: 2,
maxZoom: 18
});
L.geoJson(data, {
style: function (feature) {
return {color: feature.properties.color};
},
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.description);
}
}).addTo(map);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 我希望您使用选择交互来添加功能,但是e.coordinate显示undefined。
var select = new ol.interaction.Select({
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#0288D1',
width: 2
})
})
});
map.addInteraction(select);
select.on('select', function(e) {
var feat = new ol.Feature({
geometry: new ol.geom.Point(e.coordinate),
style: style1
});
alert(e.coordinate);
feat.setStyle(style1);
layerVector.getSource().addFeature(feat);
});
Run Code Online (Sandbox Code Playgroud)
如果有人知道原因,请告诉我在我通过这种选择交互方式单击查看器时如何获取坐标。
我正在使用 OpenLayers 从搜索结果中在地图上添加点。我可以很好地添加它们,但我想在用户进行另一次搜索时清除/删除图层。我试过使用RemoveFeature()、使用Destroy()等,但我试过的一切都不起作用。
我究竟做错了什么?
http://jsfiddle.net/9Lzc1uu2/6/
var USGSimagery = new ol.layer.Tile({
myattribute: 'USGSimagery',
source: new ol.source.TileWMS(({
url: 'http://raster.nationalmap.gov/arcgis/services/Orthoimagery/USGS_EROS_Ortho_SCALE/ImageServer/WMSServer',
params: {
'LAYERS': 0
}
}))
});
var view = new ol.View({
//projection:projection
center: ol.proj.transform(
[-12934933.3971171, 5405304.89115131], 'EPSG:3857', 'EPSG:3857'),
zoom: 18
})
var geolocStyle = new ol.style.Style({
image: new ol.style.Icon(({
anchor: [0.5, 46],
anchorXUnits: 'fraction',
anchorYUnits: 'pixels',
opacity: 1,
src: 'images/icon.png'
}))
});
var map = new ol.Map({
layers: [USGSimagery],
loadTilesWhileInteracting: true,
target: document.getElementById('map'),
view: view
});
var searchResultsStyle …Run Code Online (Sandbox Code Playgroud) 在Openlayers中,可以根据缩放级别打开或关闭某些功能.尽管查看了文档,我还没有在OpenLayers 3中找到相同的功能.有谁知道如何做到这一点?这是我放在地图上的功能ol.style.Text,只有在用户放大到特定缩放级别后才能显示.
var geoJsonObj = {
'type': 'Feature',
'geometry': JSON.parse(response.FieldList[key].Shape)
}
var vectorSource = new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geoJsonObj)
});
Fields[Field.FieldID] = new ol.layer.Vector({
projection: 'EPSG:4269',
source: vectorSource,
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'yellow',
width: 1
}),
fill: new ol.style.Fill({
color: rcisWebMapUtilities.convertHex(response.FieldList[key].Shade, '0.5')
}),
text: new ol.style.Text({
textAlign: 'Center',
text: response.FieldList[key].Acres,
scale: 1
})
})
});
Run Code Online (Sandbox Code Playgroud) 是否可以插入如下所示的半圆形?
我想将它用作矢量点标记。
RegularShape接近我的意图,但它似乎只适用于“规则形状”。
我还发现了一个使用Icon的例子,它看起来非常有用,我可以用多边形实现类似的结果。有没有更聪明的方法?
使用 Point 而不是 Polygon 并屏蔽另一半怎么样?谢谢。
我想在多边形中添加图片,但是,我在openlayers 3中没有找到这样的功能。有什么办法可以实现这一点吗?
提前致谢!
我想改善使用 OpenLayer 显示的地图的加载体验。目前,新图块的加载不是很顺利,尤其是在地图的空白区域加载图块时。我想为新图块的出现设置动画,例如通过调整要显示的新图像的不透明度。我有一种感觉,这就是传单正在做的事情。
问题是我没有找到一种方法来监听图块准备好显示的情况,更不用说如何在之后为其设置动画了。
解决这个问题的最佳方法是什么?也许我正朝着错误的方向前进。
大家好,我有一组标记是在.each循环上动态创建的,就像这样。
$.each(data, function(index, element) {
markerArr[element.id] = L.marker(map.unproject([element.LocationX,element.LocationY],map.getMaxZoom()-4)).addTo(map);
});
Run Code Online (Sandbox Code Playgroud)
我的问题是如何在单击时为每个弹出窗口打开弹出窗口,并在弹出窗口中显示唯一ID?
如果要像这样用唯一的名称声明每个标记,则可以执行此操作。
var marker1 = L.marker([158,395]).addTo(mapl);
var marker2 = L.marker([158,410]).addTo(mapl);
marker1.bindPopup("Kanye West");
marker1.on('click', function (e) {
this.openPopup();
});
marker2.bindPopup("50 Cent");
marker2.on('click', function (e) {
this.openPopup();
});
Run Code Online (Sandbox Code Playgroud)
但是我需要能够打开数组中的所有标记。
尝试这样的事情没有运气
markerArr[this].on('click', function (e) {
this.openPopup();
});
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激。
谢谢。
javascript ×6
openlayers-3 ×6
leaflet ×2
openlayers ×2
angularjs ×1
geojson ×1
gis ×1
mapbox ×1
ng-repeat ×1