What layers r u using?
If its google layers, u probably need to do a transform on your data.
mywktFormat = new OpenLayers.Format.WKT({
externalProjection: new OpenLayers.Projection("EPSG:4326"), //projection your
data is in
internalProjection: new OpenLayers.Projection("EPSG:900913") //projection you
map uses to display stuff
});
And redraw is not needed on add, only on edit.
-Original Message-
From: lis...@00l.de [mailto:lis...@00l.de]
Sent: Tuesday, June 16, 2009 10:24 AM
To: Heidt, Christopher M.; o...@00l.de; users@openlayers.org
Subject: Re: RE: [OpenLayers-Users] displaying dynamic real time data
Thanks for your reply. but I must be missing something.
Here is my code:
---
var map;
linestring1 = 'LINESTRING(10.5030879974365 52.2731513977051, ...
,10.4946889877319 52.2715492248535)';
linestring2 = 'LINESTRING(10.5044755935669 52.272144317627, ...
,10.5028915405273 52.273323059082)'; mywktFormat = new
OpenLayers.Format.WKT({}); myfeatures = new Array();
function init() {
// map initialisation, as well as adding some layers (OSM, google, etc.),
centering... working fine
layerVector = new OpenLayers.Layer.Vector("Testing");
map.addLayer(layerVector);
display();
}
function display() {
myfeatures.push(mywktFormat.read(linestring1));
layerVector.addFeatures(myfeatures);
layerVector.redraw(); // not sure if necessary, but doesn't wor either way.
window.setTimeout("display2()", 5000); } function display2() {
myfeatures.push(mywktFormat.read(linestring2));
layerVector.addFeatures(myfeatures);
layerVector.redraw(); // not sure if necessary, but doesn't wor either way.
}
---
init() is called in the body's onload-event.
The map is drawn correctly, no error is issued (firefox 3.0). The delayed
function-call is happening (verified by adding some alert()), but nothing is
drawn. If i center the map onto the features
map.zoomToExtent(layerVector.getDataExtent());
it jumps to 0°,0°, so I guess no geometry could be read from the LS.
Why???
Gerrit
- Original Message -
From: christopher.m.he...@saic.com
To: o...@00l.de, users@openlayers.org
Date: 15.06.2009 15:16:27
Subject: RE: [OpenLayers-Users] displaying dynamic real time data
> featureLayer.addFeatures() is exactly what you are looking for.
>
> Var wktFormat = new OpenLayers.Format.WKT({}); Var Features = []; For
> each linestring:
>Features.push(wktFormat.read(linestring));
> End for each
> featureLayer.addFeatures(Features)
>
> -Original Message-
> From: users-boun...@openlayers.org
> [mailto:users-boun...@openlayers.org]
> On Behalf Of Gerrit Lammert
> Sent: Friday, June 12, 2009 8:04 AM
> To: users@openlayers.org
> Subject: [OpenLayers-Users] displaying dynamic real time data
>
>
> Hi there.
>
> I'm quite new working with openlayers.
> I spent the last couple of days working on something and it is driving
> me nuts. :) I want to visualize realtime data from a database as a
> track.
> To do this I am constantly (every 5 seconds) reading data from the DB
> as LINESTRING(), and parse it using "OpenLayers.Layer.GML()" and "format:
> OpenLayers.Format.WKT".
> This does work, but what i do now is I remove the "old" layer and the
> create a new layer with updated data the way described above.
> This a) leads to a flicker and b) produces more overhead than necessary.
> I would like to rather add new data to the existing layer gradually.
> I tried to only retrieve data from the DB that changed after the last
> request parse it as a feature and add it to the layer using
> .addFeatures(), but I did not succeed.
> Is there any example page that deals with this? I searched the web,
> the OL-website and the OL-example-page without success.
> Please help,
>
> Gerrit
> ___
> Users mailing list
> Users@openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
___
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users