[OpenLayers-Users] Simple vector problem
Arnd Wippermann
arnd.wippermann at web.de
Sat Apr 24 17:20:50 EDT 2010
Hi,
var map = new OpenLayers.Map('map');
without declare any map options, means, that OpenLayers takes the default
for the map options. That means EPSG:4326 with maxExtent = [-180, -90, 180,
90].
As your data is in an other projection, OpenLayers tries to reproject the
vector data. But I think, you don't use the proj4js library, so OpenLayers
fails to reproject the data. And the unprojected data do not fall into
maxExtent for EPSG:4326;
Try something like this:
map = new OpenLayers.Map('map',
{ maxExtent: new OpenLayers.Bounds(31789.1658, 790194.4183,
337250.8970, 961865.1338), //from
http://spatialreference.org/ref/epsg/26986/
numZoomLevels: 16,
maxResolution: auto,
units: 'm',
projection: new OpenLayers.Projection("EPSG:26986"),
controls:[]
});
Arnd
_____
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von shaun.anderson at verizon.net
Gesendet: Samstag, 24. April 2010 17:22
An: users at openlayers.org
Betreff: [OpenLayers-Users] Simple vector problem
Hi All,
I am very new to OpenLayers. I am doing some testing and trying to use a GML
file for a basemap.
I have the code below, but it doesn't seem to work. I don't know if there is
an error in my code, or if it's my projection. The GML is in Massachusetts
stateplane meters NAD83. So I've tried to set the projection to that.
When the page loads I get the default OpenLayers pan and zoom controls. And
when I shift+drag I get the rectangle, but there is no vector data
displayed.
please help
thanks
<html>
<head>
<title>Open Layers Test</title>
<script type="text/javascript" src="OpenLayers/OpenLayers.js" </script>
</head>
<body>
<div style="width:100%; height:100%" id="map"></div>
<script defer="defer" type="text/javascript">
var map = new OpenLayers.Map('map');
var layer = new OpenLayers.Layer.Vector("GML", {
isBaseLayer: true,
projection: new OpenLayers.Projection("EPSG:26986"),
protocol: new OpenLayers.Protocol.HTTP({
url: "BikeTrails.gml",
format: new OpenLayers.Format.GML()
})
});
map.addLayer(layer);
map.zoomToMaxExtent();
</script>
</body>
</html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100424/8abd4e9f/attachment.html
More information about the Users
mailing list