[OpenLayers-Users] Geocoding in Spherical mercator
Esteban olm
esteban.olm at gmail.com
Fri Jul 4 03:09:52 EDT 2008
I hope this helps you...
---------- Forwarded message ----------
From: Oscar Fonts <oscar.fonts.lists at gmail.com>
Date: 2008/6/6
Subject: Re: [OpenLayers-Dev] Please, help with vectors projection over
google layer (really desperate)
To: Eric Lemoine <eric.c2c at gmail.com>
Cc: Esteban olm <esteban.olm at gmail.com>, openlayers <dev at openlayers.org>
Eric, you're faster. Catched them all while I tested...
Esteban, esta es la función init() resultante, por si la quieres aprovechar:
function init() {
var g = new OpenLayers.Projection("EPSG:4326");
var p = new OpenLayers.Projection("EPSG:900913");
var options = {
projection: p,
displayProjection: g,
units: "m",
maxResolution: 156543.0339,
maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
20037508, 20037508.34)
};
map = new OpenLayers.Map('map', options);
var layergoogle = new OpenLayers.Layer.Google("Google Normal",
{type: G_NORMAL_MAP, 'sphericalMercator': true});
var vectores = new OpenLayers.Layer.Vector("Vector Features");
map.addLayers([layergoogle, vectores]);
//line near Barcelona, spain, for example
var p1 = new OpenLayers.Geometry.Point(2, 41);
var p2 = new OpenLayers.Geometry.Point(41, 2);
var lineString = new
OpenLayers.Geometry.LineString([p1,p2]).transform(g, p);
var lineFeature = new OpenLayers.Feature.Vector(lineString,
null, null);
vectores.addFeatures([lineFeature]);
var lonLat = new OpenLayers.LonLat(2, 41).transform(g, p);
map.setCenter(lonLat, 7);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080704/30aebf6d/attachment.html
More information about the Users
mailing list