gpt4 book ai didi

javascript - 开放层功能

转载 作者:行者123 更新时间:2023-11-28 02:36:21 25 4
gpt4 key购买 nike

为什么我无法向 Vector 添加功能?此代码不起作用:

var features = [new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-70.702451, 42.374473), {className: "latarnia"})]

vectors = new OpenLayers.Layer.Vector("warstwa", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
format: new OpenLayers.Format.OSM()
}),
features : features,
projection: new OpenLayers.Projection("EPSG:4326")});

map.addLayers([vectors]);

我的意思是向量根本没有特征。我试过了

layer.addFeatures([feature]);

但它也失败了。

最佳答案

看来你的 map 和点的投影不一样。 map 投影是 EPSG:4326 ,但点投影似乎是 EPSG:3857 。

也许对你有帮助

conv_latlon = new OpenLayers.LonLat(-70.702451, 42.374473).transform('EPSG:3857', 'EPSG:4326')//transform point 
var features = [new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(conv_latlon.lon, conv_latlon.lat), {className: "latarnia"})]

关于javascript - 开放层功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13431449/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com