这是我第一次在stackoverflow上使用Openlayers &谷歌地图。OpenLayers谷歌地图投影问题带有KML
我一直在浏览不同的论坛&网站,包括OpenLayers.org,以解决我的问题。我已经完成了以下组合的搜索:openlayers,google map投影和球形mercator ...但我还没有找到解决方案。
问题:当我放大和缩小地图时,来自Web服务调用(func setDataSource)的KML数据正在移动。我的猜测是我的代码中的预测是错误的或可能是错误的。我没有关于地图投影任何背景,因此难以消化映射术语在线:-(。有人能帮忙吗?
//start here
var options = {
projection: new OpenLayers.Projection("EPSG:900913"),
displayProjection: new OpenLayers.Projection("EPSG:4326"),
units: "m",
numZoomLevels: 18,
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508)};
//*map = new OpenLayers.Map('map');
map = new OpenLayers.Map('map', options);
var gphy = new OpenLayers.Layer.Google(
"Google Street",
{'sphericalMercator':true});
// Add the background images via WMS
var bglayer = new OpenLayers.Layer.WMS("OpenLayers WMS",
"http://labs.metacarta.com/wms/vmap0", {layers: 'basic'}, {'reproject': true});
//map.addLayer(bglayer);
map.addLayers([gphy, bglayer]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent(); //* Zoom all the way out, this command also initalizes the map
OpenLayers.Console.log("initialized");
}
function setDataSource() {
OpenLayers.Console.log("Setting data source to " + OpenLayers.Util.getElement('loc').value);
if (layer != undefined) {map.removeLayer(layer)};
if (selectControl != undefined) {map.removeControl(selectControl)};
// Encode the destination url as a parameter string.
var params = OpenLayers.Util.getParameterString({url:OpenLayers.Util.getElement('loc').value})
// Make the http request to the transformer, with the destination url as a parameter.
layer = new OpenLayers.Layer.GML("KML", transformerURL + params,
{
format: OpenLayers.Format.KML,
formatOptions: {
extractStyles: true,
extractAttributes: true,
maxDepth: 2,
//projection: new OpenLayers.Projection("EPSG:4326"),
}
});
map.addLayer(layer);
谢谢!
[GIS.stackexchange.com](http://gis.stackexchange.com/)上的家伙和女孩可能会更容易地帮助你下次.. – DefenestrationDay 2011-07-07 12:36:57
也许你可以帮助我这个问题 [的OpenLayers谷歌地图边框] [1] [1]:http://stackoverflow.com/questions/29120583/how-to-remove-countries-borders-from-a-google-地图集成在操作员中 – 2015-03-18 14:18:31