Nice one, I heard about proj4js, thought never used it Thanks for this hint
Jachym
Mike Adair píše v Po 14. 01. 2008 v 10:09 -0500:
> Note that this should work too, and allows you to handle points in
> coordinate systems other than EPSG:4326:
>
> - include proj4js in your app via the <script> tag
>
> - then:
>
> preFeatureInsert = function(feature) {
> var src = new OpenLayers.Projection('EPSG:4326');
> var dest = new OpenLayers.Projection('EPSG:900913');
> for (var i = 0; i < feature.geometry.components.length; i++) {
> OpenLayers.Projection.transform(feature.geometry.components[i], src,
> dest);
> }
> };
>
> You may need to skip transforming the last point in the components if it is a
> repeat of the first point (for polygons).
>
> Mike
>
>
>
> Jachym Cepicky wrote:
> > Hi,
> >
> > Jachym Cepicky píše v Po 14. 01. 2008 v 14:11 +0100:
> >
> >> [...]
> >>
> >> Then I tried to redefine preFeatureInsert method of
> >> OpenLayers.Layer.Vector, to get coordinates
> >> for all features in epsg:900913
> >>
> >> preFeatureInsert = function(feature) {
> >> for (var i = 0; i < feature.geometry.components.length; i++) {
> >> var x = feature.geometry.components[i].x;
> >> var y = feature.geometry.components[i].y;
> >> var ll = kolo.forwardMercator(x,y);
> >>
> >> x = x * 20037508.34 / 180;
> >> y = Math.log(Math.tan((90 + y) * Math.PI / 360)) / (Math.PI / 180);
> >>
> >> y = y * 20037508.34 / 180;
> >>
> >> feature.geometry.components[i].x = x;
> >> feature.geometry.components[i].y = y;
> >>
> >> }
> >> };
> >>
> >> // the vector map definition
> >>
> >> var vector = new OpenLayers.Layer.GML("Vector","gml.xml",
> >> {preFeatureInsert:preFeatureInsert});
> >>
> >>
> > this works. the error was somewhere else
> >
> > j
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > [email protected]
> > http://openlayers.org/mailman/listinfo/users
> >
--
Jachym Cepicky
e-mail: [EMAIL PROTECTED]
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
signature.asc
Description: Toto je digitálně podepsaná část zprávy
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
