我有个问题.我需要知道开放图层地图的实际缩放
$scope.refreshMap = function (lat, long) {
map.setView(new ol.View({
projection: 'EPSG:4326',
center: [long, lat],
zoom: "here I do not know what to put"
}));
};
Run Code Online (Sandbox Code Playgroud)
我尝试map.getZoom()但它不起作用.logcat会让我失望
Uncaught TypeError: Object #<S> has no method 'getZoom'
Run Code Online (Sandbox Code Playgroud)
我正在使用openlayers版本:v3.16.0
我试图找到一些提示,我应该搜索这个主题,但我找不到任何东西 - 我花了很多时间在这上面.
我还试图从OpenLayers地图中获取当前显示的视口中的当前坐标,以仅添加当前视口的当前边界框中的这些矢量.
我一直在努力openlayers 3并创造了一个填充canvasPattern.填充工作,问题是它不能按预期工作.
我希望填充随着它填充的几何体移动,但正如您将在此示例中看到的那样:
http://fiddle.jshell.net/luigibosca/Lwrbuxfd/14/
如果您移动地图,您会注意到填充是绝对定位的,而不是相对于它填充的几何体.
在此先感谢您的帮助!
当我在OpenLayers地图中绘制多边形时,我想知道标记是否在多边形内部.我在OpenLayers API中搜索过,但没有找到解决方案.
你可以在这个链接中看到我的完整代码.
我的印象是我必须修改此功能:
function addInteraction() {
var value = typeSelect.value;
if (value !== 'None') {
draw = new ol.interaction.Draw({
source: vectorSource,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
});
map.addInteraction(draw);
draw.on('drawend',function(e){
//Here
});
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
我有一个很大的地图应用程序,因此,为了代表我将只提供一部分代码。因此,这就是我尝试从地图上删除所有图层的方式:
map.getLayers().forEach(function (layer) {
map.removeLayer(layer);
});
//map.getOverlays().clear(); <-- also tried this, but to no effect
Run Code Online (Sandbox Code Playgroud)
而且我有一些随机行为-有时删除了所有图层,有时没有删除。这是完全随机的,因此不能保证您可以重现此问题。因此,仅从概念上了解为什么会发生就足够了。
解
显然这是一个ol3错误,因为如果我循环并删除两次,它将开始工作:
map.getLayers().forEach(function (layer) {
map.removeLayer(layer);
});
//for some crazy reason I need to do it twice.
map.getLayers().forEach(function (layer) {
map.removeLayer(layer);
});
Run Code Online (Sandbox Code Playgroud)
可能不是错误,并且有一些秘密方法可以清除地图。但是我不知道。
在OpenMapTiles的文档中,它可以为MapBox GL JS提供矢量图块。
但是在挖掘这两个项目的文档时,我没有找到一个选择:如何配置自托管的MapBox GL JS库以使用自托管的OpenMapTiles服务器中的图块?
我试图在openlayers 3中做基于规则的样式,这是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>CONFIG</title>
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://openlayers.org/en/v3.8.2/css/ol.css" type="text/css">
<script src="http://openlayers.org/en/v3.8.2/build/ol.js"></script>
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div id="map" class="map"></div>
</div>
</div>
<script>
var layerStyle = {
default: {
style: new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(0, 0, 0, 1.0)',
width: 0.5
}),
fill: new ol.style.Fill({
color: 'rgba(0, 255, 0, 0.5)'
})
})
},
filter: [{
type: "AND",
rules: [{
type: "==",
property: "CODE",
value: "16"
}, {
type: …Run Code Online (Sandbox Code Playgroud) 我试图找出Openlayers 3中图层上可见的所有功能(视口).
如果我向地图添加点击事件,我可以找到一个功能,如下所示.但我无法找到视口中可见的所有功能.任何人都可以帮忙吗?
map.on('click', function(evt) {
var feature = map.forEachFeatureAtPixel(evt.pixel,
function(feature, layer) {
return feature;
});
});
Run Code Online (Sandbox Code Playgroud) 当我从OpenLayers 2.12切换到2.13.1时,所有Google Maps图层都停止工作.当我使用图层切换器时,地图区域变为白色.
我在浏览器的开发控制台中看不到任何错误消息,并且所有文件都已成功加载.
我正在创建这样的图层:
var layerGoogleMapsNormal = new OpenLayers.Layer.Google("Google Normal" , { type : google.maps.MapTypeId.ROADMAP, sphericalMercator : true });
var layerGoogleMapsPhysical = new OpenLayers.Layer.Google("Google Physical" , { type : google.maps.MapTypeId.TERRAIN, sphericalMercator : true });
Run Code Online (Sandbox Code Playgroud)
其他层(OSM,WMS)工作正常.
在我写这篇文章时,我发现OpenLayers的例子也不能正常工作.
http://dev.openlayers.org/examples/google.html
可能是谷歌做出了重大改变吗?有没有其他人有同样的问题,有没有人知道解决方案?
备注:我看过OpenLayers3,但它的API非常不同,我认为我们永远无法将所有代码移植到那里.我们无法说服我们的客户为重写所有的映射内容来使用OL3付费,所以我想这个项目永远停留在2.x分支......
我正在构建一个使用Geolocation的应用程序,使用Open Layers加载Bing Map Layer.我想仅通过触摸来控制缩放,因此想要删除默认的缩放按钮.理想情况下,我想至少移动"i"按钮,这样它就不会与圆形白色按钮发生冲突.
这是当前呈现方式的屏幕截图:
除了Geolocation代码之外,这就是我添加Bing Maps图层的方式,我假设我会添加代码来删除这些,但我尝试的所有内容都没有区别:
var styles = [
'Road',
'Aerial',
'AerialWithLabels',
'ordnanceSurvey'
];
var layers = [];
var i, ii;
for (i = 0, ii = styles.length; i < ii; ++i) {
layers.push(new ol.layer.Tile({
visible: false,
preload: Infinity,
source: new ol.source.BingMaps({
key: 'my key is here in the real version',
imagerySet: styles[i],
disableZooming: true,
// use maxZoom 19 to see stretched tiles instead of the BingMaps
// "no photos at this zoom level" tiles
maxZoom: 19 …Run Code Online (Sandbox Code Playgroud) javascript ×8
openlayers-3 ×7
openlayers ×2
bing-maps ×1
google-maps ×1
html5-canvas ×1
ios ×1
mapbox ×1
mapbox-gl-js ×1
openmaptiles ×1