Raphael,
I don't know of a simple function to do it, but if you get the line as a
feature, it should be as easy as:
pointArray = lineFeature.geometry.components;
pointFeatures = [];
for (var i = 0; i < pointArray.length; i++) {
pointFeatures.push( new OpenLayers.Feature.Vector( pointArray[i] ) );
}
"pointFeatures" will then be an array of point vector features, suitable for
sending to layer.addFeatures.
z
On Fri, Nov 5, 2010 at 4:09 AM, Raphael Frank <[email protected]>wrote:
> Thanks for the quick reply. Unfortunately this didn't change anything, I
> still get the line and no points. Is there no simple function to change from
> "line" to "point" using geometry?
>
>
> On 11/4/10 6:44 PM, David Zwarg wrote:
>
> Try:
>
> var lgpx = new OpenLayers.Layer.GML("Green", "green.gpx", {
> ...
> style: {strokeColor: "green", strokeWidth: 10, strokeOpacity: 0.5,
> pointRadius: 5, fillColor: "green", fillOpacity: 0.5},
> ...
> });
>
> That might get you points on the line as well. The GPX is probably
> rendering a Geometry of LineString or MultiLineString type, in which case it
> may not draw every point explicitly. If you want to draw a bunch of points,
> you may have to pull out the point geometry from that LineString, and add
> each point as a discrete feature. Someone correct me if I'm wrong, here.
>
> -z
>
> On Thu, Nov 4, 2010 at 1:18 PM, raphx <[email protected]> wrote:
>
>>
>> Hi,
>>
>> I'm new to Openlayer and Javascript in general. I have a very simple
>> question, how to display simple "points" like circles or square on a map
>> using coordinates stored in a GPX file. I found an example how to draw a
>> line from one entry to the next however I couldn't find any example using
>> points. Any idea?
>>
>> var lgpx = new OpenLayers.Layer.GML("Green", "green.gpx", {
>> format: OpenLayers.Format.GPX,
>> style: {strokeColor: "green", strokeWidth: 10, strokeOpacity: 0.5},
>> projection: new OpenLayers.Projection("EPSG:4326")
>> });
>>
>> map.addLayer(lgpx);
>> --
>> View this message in context:
>> http://osgeo-org.1803224.n2.nabble.com/Display-points-from-GPX-tp5706149p5706149.html
>> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>> _______________________________________________
>> Users mailing list
>> [email protected]
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>
>
>
>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users