I'm trying to create KML files manually (XML format) by extracting data from a postGIS database with "geography" values in a column.
But i believe i need to transform the projection of each row in the database from EPSG:4326 to EPSG: 900913.. How can i do that?
Code:
map = new OpenLayers.Map({
maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
numZoomLevels:16,
zoom: 0,
maxResolution:156543.0339,
units:'m',
projection: "EPSG:900913",
displayProjection: new OpenLayers.Projection("EPSG:4326"),
div: "map_canvas",
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.MousePosition(),
new OpenLayers.Control.LayerSwitcher()
],
});
var KML = new OpenLayers.Layer.Vector("KML", {
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "assets/text.kml",
format: new OpenLayers.Format.KML({
extractStyles: false,
extractAttributes: true
})
})
});
- Coordinate system in database: (one "Area") / Polygon.
-179.999995473772 -89.9999977368861,-89.9999954737723 -89.9999977368861,4.52622771263123e- 06 -89.9999977368861,90.0000045262277 -89.9999977368861,179.999995473772 -89.9999977368861,179.999995473772 89.9999977368861,90.0000045262277 89.9999977368861,4.52622771263123e-06 89.9999977368861,-89.9999954737723 89.9999977368861,-179.999995473772 89.9999977368861,-179.999995473772 -89.9999977368861
Current error:
Uncaught Bad LineString point coordinates: -179.999995473772
Best Answer
i found a way to do it:
Hope this helps anyone else :)