[OpenLayers-Users] vector doesn't display

Matt Priour mpriour at kestrelcomputer.com
Wed Dec 12 10:11:01 PST 2012


You have to actually load the GeoJSON features into the layer.

First, look at the following examples:

http://openlayers.org/dev/examples/geojson-reprojected.html
http://openlayers.org/dev/examples/cartodb-geojson.html

They both use a Fixed strategy which is the best one if you want to load 
your data once and have it in a static file or known URL.

You would add your style definition to the vector layer definition they 
present in these examples and then you would have a layer with features 
to be symbolized.

Matt Priour
Kestrel Computer Consulting


On 12/12/2012 6:21 AM, Gery . wrote:
> Hello,
>
> I have some features in GeoJSON format I want to display, so I did this:
>
> [code]
>         var vectorLayer = null;
>
>         var vectorStyle =
>         {
>             graphicName: 'square',
>             strokeColor: '#222',
>             fillColor: '#222'
>         };
>
>         var styleDefault = OpenLayers.Util.applyDefaults(
>             vectorStyle,
>             OpenLayers.Feature.Vector.style['default']
>         );
>
>         vectorLayer = new OpenLayers.Layer.Vector('search',
>         {
>             styleMap: new OpenLayers.StyleMap(
>             {
>                 'default': styleDefault
>             }
>             ),
>             displayInLayerSwitcher: true
>         }
>         );
> [/code]
>
> but they don't appear in the map, my question is if this is enough to 
> get the features displayed or do I need something else there? if this 
> is enough, I should think that this problem is about how the features 
> are being read by OL. In fact, this doesn't work either:
>
> var ll = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);
> mapPanel.map.setCenter(ll);
>
> I get:
>
> feature is not defined
> [Break On This Error] 	
> var ll = new OpenLayers.LonLat(feature.geometry.x, feature.geometry.y);
>
>
> why should this happen? thanks in advance
>
>
>
> __________________________________________________________________________________________
> Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas 
> si NO es necesario.
> Think green - keep it on the screen. Do NOT print if it is NOT necessary.
> Denken Sie an die Umwelt- bewahren Sie es auf dem Bildschirm. Drucken 
> Sie NICHT, wenn es NICHT notwendig ist.
>
>
> _______________________________________________
> 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/20121212/30e3d3ae/attachment.html>


More information about the Users mailing list