[Geojson] Adding extra data to a geojson string
Tim Schaub
tschaub at opengeo.org
Sun Nov 1 17:56:23 PST 2009
Hey-
Chitraleka Appalanaidu wrote:
> Hi all,
>
> I have a geojson file that I pass to the penLayers.Format.GeoJSON
> parser. This parser converts the a geojson string (as below) to a
> OpenLayers.Vector.Feature object and adds it into an OpenLayers Vector
> layer (that performs clustering)
>
> {
> "type": "FeatureCollection",
> "features": [
> {"type":"Feature", "id":"1", "properties":{},
> "geometry":{"type":"Point", "coordinates":[143, -35.91]}},
> {"type":"Feature", "id":"2", "properties":{},
> "geometry":{"type":"Point", "coordinates":[144, -37.81667]}}
> ]
> }
>
>
> The problem with adding it into a clustering layer is that any
> properties I add into the "properties":{} field in the above geojson
> file will get overriden (because clustering will cause a count value to
> be entered into the properties list).
>
> I would like to add other information about a point in the geojson file
> above. Is there any other key-value pair i can use to do this? I have
> tried the 'fid' and 'style' key-value pairs but the parser does not seem
> to parse them out into a OpenLayers.Vector.Feature object.
>
In terms of what you can do in GeoJSON, any other members (with
non-reserved names) are allowed on feature objects.
I think your issue is exclusively an OpenLayers issue. OpenLayers will
parse whatever you put in the properties member and make this available
at feature.attributes (as you've seen). When you use the cluster
strategy, you can get at the original features in the cluster via
feature.cluster.
If you haven't already, you could write an email to the OpenLayers dev
list with more specific questions.
Tim
> Thank you.
>
> Kind regards,
> Chitra
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Geojson mailing list
> Geojson at lists.geojson.org
> http://lists.geojson.org/listinfo.cgi/geojson-geojson.org
--
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.
More information about the GeoJSON
mailing list