[OpenLayers-Users] Google and UK grid vector overlay
Mauro Bianchi
bianchimro at gmail.com
Tue Jan 13 05:50:59 EST 2009
Dear all,
I'm pretty new to OL and I want to do the following
1) have a google layer as a base layer
2) overlay a vector layer and add points programmatically. Points
coordinates are given in the UK national grid system (OSGB , which
should be EPSG:27700)
I could convert points coordinates externally, but I'd prefer to do it
directly into OpenLayers, if possibile.
I tried different methods but cannot get it working.
Any help would be really appreciated!
Thank you
Mauro
My code is the following
var map;
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.34)
};
map = new OpenLayers.Map('map', options);
//google maps layer, physical
var gphy = new OpenLayers.Layer.Google(
"Google Physical",
{type: G_PHYSICAL_MAP, numZoomLevels: 20, 'sphericalMercator':true}
);
map.addLayers([gphy]);
//a vector layer where i want to add points programmatically
var vectorLayer = new OpenLayers.Layer.Vector("My Geometry");
//this is a point that i want to add in UK grid coordinates
var point = new OpenLayers.Geometry.Point(519000, 165222).transform(
new OpenLayers.Projection("EPSG:27700"), map.projection);
var pointFeature = new OpenLayers.Feature.Vector(point);
vectorLayer.addFeatures([pointFeature]);
map.addLayer(vectorLayer);
//controls and centering
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new
OpenLayers.LonLat(-0.126343,51.539502).transform(map.displayProjection,
map.projection), 10);
--
Mauro Bianchi
bianchimro at gmail.com
More information about the Users
mailing list