[OpenLayers-Users] Moving a OpenLayers.Feature.Vector: How?

Bart van den Eijnden bartvde at opengeo.org
Mon Sep 24 06:06:02 PDT 2012


The move function already redraws.

The move function takes an OpenLayers.LonLat and not 2 separate arguments so try:

> geo_pointFeature.move(geo); 

Best regards,
Bart

-- 
Bart van den Eijnden
OpenGeo - http://opengeo.org
Expert service straight from the developers.



On Sep 24, 2012, at 2:59 PM, darethehair <darethehair at gmail.com> wrote:

> I would like to move (rather than destroy and rebuild) a
> 'OpenLayers.Feature.Vector' by simply changing its lat/long, but the 'move'
> makes the feature disappear.  Do I have to refresh/redraw something to
> finish the task?  Here is the basic code that I have now:
> 
> ...
> geo_point_vectors = new OpenLayers.Layer.Vector('Geo Point');
> geo = new OpenLayers.LonLat(geo_long, geo_lat).transform(epsg4326,
> epsg900913);
> geo_point = new OpenLayers.Geometry.Point(geo.lon, geo.lat); 
> geo_pointFeature = new OpenLayers.Feature.Vector(geo_point, {title: "GEO"},
> {
>        fillColor : "Yellow",
>        fillOpacity : 1.0,
>        strokeColor : "Orange",
>        strokeOpacity : 1,
>        strokeWidth : 1,
>        pointRadius : 5
> });     
> geo_point_vectors.addFeatures([geo_pointFeature]);
> map.addLayers([geo_point_vectors]);
> ...
> geo = new OpenLayers.LonLat(new_geo_long, new_geo_lat).transform(epsg4326,
> epsg900913);
> geo_pointFeature.move(geo.lon, geo.lat); 
> ...
> 
> I would think that lots of folks have already written similar code e.g. for
> tracking a moving car GPS position, but I found it very difficult to find
> any examples out there (!).
> 
> P.S. I was going to wrap my code in 'raw' markers for this post, but the
> last time I tried it the text was invisible to everyone -- so I left it as
> plain text..  Did I do something wrong?
> 
> 
> 
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/Moving-a-OpenLayers-Feature-Vector-How-tp5004007.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120924/1b467c64/attachment.html>


More information about the Users mailing list