Problem with GML features

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with GML features

Dmitri Mizerkin-2
Hello everybody!

I'm experiencing problems with handling the features of a GML layer, which is loaded when the page is opened. The problem is that after the 'loanend' event is raised, the features-property of the layer stays empty for some more time, so there is no way to examine the features in this handler. In my case I need to extract the bounds-properties of the features to construct an common bounds-object for zooming (the action should simulate feature selection and zooming to the selection).

Any ideas, how this could work?

Here's my code snapshot:

function SelectFeature() {
  var layer = GetLayerByName(FEATURE_LAYER); //returns a MapServer layer to send a request on
  if (layer == null)
    return;
  var selection_url = CreateWFSGetFeatureRequest(layer, FIELD_NAME, FIELD_VALUE); //creates a WFS GetFeature-request
  if ((selection != null)&&(selection.map != null)) {
    OLMap.removeLayer (selection);
    selection = null; 
  }
  selection = new OpenLayers.Layer.GML("Selected Objects", selection_url);
  OLMap.addLayer(selection);
  selection.displayInLayerChooser = false;
  selection.events.register ("loadend", selection, ZoomToSelection);
  selection.events.triggerEvent("loadend");
}

function ZoomToSelection() {
  var bounds = ComputeSelectionBounds();
  if (bounds == null)
    return;
  OLMap.zoomToExtent(bounds);
}

Thanks in advance!

--
Regards,
Dmitri
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Fwd: Problem with GML features

Dmitri Mizerkin-2
Hi!

I haven't got any reaction to my previous mail, so I'm trying to point your attention to my problem again in this follow-up.
The problem is: after loading a GML layer the features collection of the layer stays empty (at least for some time), which means that there's no way to handle those in the loadend-event of the layer. Is there another event, which is raised after the features collection of the loaded layer is initialized? Is there any rational workaround?

My next action would be setting up a timer with the setTimeout(...) function and trying to access the features collection after some time interval hoping that the features are finally loaded. However, this seems to be a very hardcoded solution.

Cheers,
Dmitri Mizerkin

---------- Forwarded message ----------
From: Dmitri Mizerkin <[hidden email]>
Date: 05.07.2007 10:33
Subject: Problem with GML features
To: [hidden email]

Hello everybody!

I'm experiencing problems with handling the features of a GML layer, which is loaded when the page is opened. The problem is that after the 'loanend' event is raised, the features-property of the layer stays empty for some more time, so there is no way to examine the features in this handler. In my case I need to extract the bounds-properties of the features to construct an common bounds-object for zooming (the action should simulate feature selection and zooming to the selection).

Any ideas, how this could work?

Here's my code snapshot:

function SelectFeature() {
  var layer = GetLayerByName(FEATURE_LAYER); //returns a MapServer layer to send a request on
  if (layer == null)
    return;
  var selection_url = CreateWFSGetFeatureRequest(layer, FIELD_NAME, FIELD_VALUE); //creates a WFS GetFeature-request
  if ((selection != null)&&(selection.map != null)) {
    OLMap.removeLayer (selection);
    selection = null; 
  }
  selection = new OpenLayers.Layer.GML("Selected Objects", selection_url);
  OLMap.addLayer(selection);
  selection.displayInLayerChooser = false;
  selection.events.register ("loadend", selection, ZoomToSelection);
  selection.events.triggerEvent("loadend");
}

function ZoomToSelection() {
  var bounds = ComputeSelectionBounds();
  if (bounds == null)
    return;
  OLMap.zoomToExtent(bounds);
}

Thanks in advance!

--
Regards,
Dmitri

--
Gruß,
Dmitri
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Problem with GML features

Tim Schaub-2
Hey Dmitri-

Dmitri Mizerkin wrote:
> Hi!
>
> I haven't got any reaction to my previous mail, so I'm trying to point
> your attention to my problem again in this follow-up.
> The problem is: after loading a GML layer the features collection of the
> layer stays empty (at least for some time), which means that there's no
> way to handle those in the loadend-event of the layer. Is there another
> event, which is raised after the features collection of the loaded layer
> is initialized? Is there any rational workaround?

You're right.  There is no good way to do what you want right now.  I
assume you're talking about the WFS layer in vector mode (as opposed to
marker mode).  When the tile for this layer is drawn a WFS request is
made asynchronously - when this request returns, the GML is parsed and
added to your layer.  As each feature is added to your layer, the
optional onFeatureInsert property of your layer (a function) is called.
  This is not handy if you want to know when the features are done being
added.

I thought there was a ticket out there already for this.  I'll check -
and add one if not.

I'm hoping to do some work on the WFS layer in the near future.  This
and other issues will likely get addressed then.

Tim


>
> Cheers,
> Dmitri Mizerkin
>
> ---------- Forwarded message ----------
> From: *Dmitri Mizerkin* <[hidden email] <mailto:[hidden email]>>
> Date: 05.07.2007 10:33
> Subject: Problem with GML features
> To: [hidden email] <mailto:[hidden email]>
>
> Hello everybody!
>
> I'm experiencing problems with handling the features of a GML layer,
> which is loaded when the page is opened. The problem is that after the
> 'loanend' event is raised, the features-property of the layer stays
> empty for some more time, so there is no way to examine the features in
> this handler. In my case I need to extract the bounds-properties of the
> features to construct an common bounds-object for zooming (the action
> should simulate feature selection and zooming to the selection).
>
> Any ideas, how this could work?
>
> Here's my code snapshot:
>
> function SelectFeature() {
>   var layer = GetLayerByName(FEATURE_LAYER); //returns a MapServer layer
> to send a request on
>   if (layer == null)
>     return;
>   var selection_url = CreateWFSGetFeatureRequest(layer, FIELD_NAME,
> FIELD_VALUE); //creates a WFS GetFeature-request
>   if ((selection != null)&&(selection.map != null)) {
>     OLMap.removeLayer (selection);
>     selection = null;
>   }
>   selection = new OpenLayers.Layer.GML("Selected Objects", selection_url);
>   OLMap.addLayer(selection);
>   selection.displayInLayerChooser = false;
>   selection.events.register ("loadend", selection, ZoomToSelection);
>   selection.events.triggerEvent("loadend");
> }
>
> function ZoomToSelection() {
>   var bounds = ComputeSelectionBounds();
>   if (bounds == null)
>     return;
>   OLMap.zoomToExtent(bounds);
> }
>
> Thanks in advance!
>
> --
> Regards,
> Dmitri
>
> --
> Gruß,
> Dmitri
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/users

_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Problem with GML features

Erik Uzureau-3
I would note that the work that I'm doing in my untiled3 branch could
be helpful for this.

The problem is that WFS layer is no longer subclassed off of grid. I
think this is a mistake, but so be it.

At the very least, the work with sending loadStart and loadEnd events
can be a good model.

--erik


On 7/6/07, Tim Schaub <[hidden email]> wrote:

> Hey Dmitri-
>
> Dmitri Mizerkin wrote:
> > Hi!
> >
> > I haven't got any reaction to my previous mail, so I'm trying to point
> > your attention to my problem again in this follow-up.
> > The problem is: after loading a GML layer the features collection of the
> > layer stays empty (at least for some time), which means that there's no
> > way to handle those in the loadend-event of the layer. Is there another
> > event, which is raised after the features collection of the loaded layer
> > is initialized? Is there any rational workaround?
>
> You're right.  There is no good way to do what you want right now.  I
> assume you're talking about the WFS layer in vector mode (as opposed to
> marker mode).  When the tile for this layer is drawn a WFS request is
> made asynchronously - when this request returns, the GML is parsed and
> added to your layer.  As each feature is added to your layer, the
> optional onFeatureInsert property of your layer (a function) is called.
>   This is not handy if you want to know when the features are done being
> added.
>
> I thought there was a ticket out there already for this.  I'll check -
> and add one if not.
>
> I'm hoping to do some work on the WFS layer in the near future.  This
> and other issues will likely get addressed then.
>
> Tim
>
>
> >
> > Cheers,
> > Dmitri Mizerkin
> >
> > ---------- Forwarded message ----------
> > From: *Dmitri Mizerkin* <[hidden email] <mailto:[hidden email]>>
> > Date: 05.07.2007 10:33
> > Subject: Problem with GML features
> > To: [hidden email] <mailto:[hidden email]>
> >
> > Hello everybody!
> >
> > I'm experiencing problems with handling the features of a GML layer,
> > which is loaded when the page is opened. The problem is that after the
> > 'loanend' event is raised, the features-property of the layer stays
> > empty for some more time, so there is no way to examine the features in
> > this handler. In my case I need to extract the bounds-properties of the
> > features to construct an common bounds-object for zooming (the action
> > should simulate feature selection and zooming to the selection).
> >
> > Any ideas, how this could work?
> >
> > Here's my code snapshot:
> >
> > function SelectFeature() {
> >   var layer = GetLayerByName(FEATURE_LAYER); //returns a MapServer layer
> > to send a request on
> >   if (layer == null)
> >     return;
> >   var selection_url = CreateWFSGetFeatureRequest(layer, FIELD_NAME,
> > FIELD_VALUE); //creates a WFS GetFeature-request
> >   if ((selection != null)&&(selection.map != null)) {
> >     OLMap.removeLayer (selection);
> >     selection = null;
> >   }
> >   selection = new OpenLayers.Layer.GML("Selected Objects", selection_url);
> >   OLMap.addLayer(selection);
> >   selection.displayInLayerChooser = false;
> >   selection.events.register ("loadend", selection, ZoomToSelection);
> >   selection.events.triggerEvent("loadend");
> > }
> >
> > function ZoomToSelection() {
> >   var bounds = ComputeSelectionBounds();
> >   if (bounds == null)
> >     return;
> >   OLMap.zoomToExtent(bounds);
> > }
> >
> > Thanks in advance!
> >
> > --
> > Regards,
> > Dmitri
> >
> > --
> > Gruß,
> > Dmitri
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > [hidden email]
> > http://openlayers.org/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: Problem with GML features

Dmitri Mizerkin-2
Hello,

the workaround suggested by Tim will do it, because I want to zoom to a single feature at this time.
Thanks for the help, guys!

Cheers,
Dmitri

2007/7/6, Erik Uzureau < [hidden email]>:
I would note that the work that I'm doing in my untiled3 branch could
be helpful for this.

The problem is that WFS layer is no longer subclassed off of grid. I
think this is a mistake, but so be it.

At the very least, the work with sending loadStart and loadEnd events
can be a good model.

--erik


On 7/6/07, Tim Schaub <[hidden email]> wrote:

> Hey Dmitri-
>
> Dmitri Mizerkin wrote:
> > Hi!
> >
> > I haven't got any reaction to my previous mail, so I'm trying to point
> > your attention to my problem again in this follow-up.
> > The problem is: after loading a GML layer the features collection of the
> > layer stays empty (at least for some time), which means that there's no
> > way to handle those in the loadend-event of the layer. Is there another
> > event, which is raised after the features collection of the loaded layer
> > is initialized? Is there any rational workaround?
>
> You're right.  There is no good way to do what you want right now.  I
> assume you're talking about the WFS layer in vector mode (as opposed to
> marker mode).  When the tile for this layer is drawn a WFS request is
> made asynchronously - when this request returns, the GML is parsed and
> added to your layer.  As each feature is added to your layer, the
> optional onFeatureInsert property of your layer (a function) is called.
>   This is not handy if you want to know when the features are done being
> added.
>
> I thought there was a ticket out there already for this.  I'll check -
> and add one if not.
>
> I'm hoping to do some work on the WFS layer in the near future.  This
> and other issues will likely get addressed then.
>
> Tim
>
>
> >
> > Cheers,
> > Dmitri Mizerkin
> >
> > ---------- Forwarded message ----------
> > From: *Dmitri Mizerkin* <[hidden email] <mailto: [hidden email]>>
> > Date: 05.07.2007 10:33
> > Subject: Problem with GML features
> > To: [hidden email] <mailto:[hidden email]>
> >
> > Hello everybody!
> >
> > I'm experiencing problems with handling the features of a GML layer,
> > which is loaded when the page is opened. The problem is that after the
> > 'loanend' event is raised, the features-property of the layer stays
> > empty for some more time, so there is no way to examine the features in
> > this handler. In my case I need to extract the bounds-properties of the
> > features to construct an common bounds-object for zooming (the action
> > should simulate feature selection and zooming to the selection).
> >
> > Any ideas, how this could work?
> >
> > Here's my code snapshot:
> >
> > function SelectFeature() {
> >   var layer = GetLayerByName(FEATURE_LAYER); //returns a MapServer layer
> > to send a request on
> >   if (layer == null)
> >     return;
> >   var selection_url = CreateWFSGetFeatureRequest(layer, FIELD_NAME,
> > FIELD_VALUE); //creates a WFS GetFeature-request
> >   if ((selection != null)&&(selection.map != null)) {
> >     OLMap.removeLayer (selection);
> >     selection = null;
> >   }
> >   selection = new OpenLayers.Layer.GML ("Selected Objects", selection_url);
> >   OLMap.addLayer(selection);
> >   selection.displayInLayerChooser = false;
> >   selection.events.register ("loadend", selection, ZoomToSelection);
> >   selection.events.triggerEvent("loadend");
> > }
> >
> > function ZoomToSelection() {
> >   var bounds = ComputeSelectionBounds();
> >   if (bounds == null)
> >     return;
> >   OLMap.zoomToExtent(bounds);
> > }
> >
> > Thanks in advance!
> >
> > --
> > Regards,
> > Dmitri
> >
> > --
> > Gruß,
> > Dmitri
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Users mailing list
> > [hidden email]
> > http://openlayers.org/mailman/listinfo/users
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://openlayers.org/mailman/listinfo/users
>
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users


_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users