getDataExtent delay problem

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

getDataExtent delay problem

Marcelo-2
Hi List, 

I am having a problem that i just cannot find the solution. I want just to load a base WMS layer and a KML file on it. The problem is that I want to display the map just arround the bounding box of the KML file but the method getDataExtent only returns something usefull when the method has returned. Some ideias ?

Browser: Google Chrome, 
OpenLayers: From SVN on 23-07-2011
 Here is the code I am using:

function init() {
        document.namespaces;
wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{ layers: 'basic'},
{ 'maxExtent': new OpenLayers.Bounds(-180,-90,180,90), 'maxResolution': "auto" }
);

var http = new OpenLayers.Protocol.HTTP({
               url: "file.kml",
              format: new OpenLayers.Format.KML({ extractStyles: false })
         });

var sta = [new OpenLayers.Strategy.Fixed({ preload: true } )];
station = new OpenLayers.Layer.Vector("Stations", { strategies: sta, protocol: http })

map = new OpenLayers.Map('map');
map.addLayers([wms, station]);
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.zoomToMaxExtent();
map.zoomToExtent(station.getDataExtent());
}

and the error i am getting on the console:

OpenLayers.js:526Uncaught TypeError: Cannot call method 'getCenterLonLat' of null

cheers, 

Marcelo

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

Re: getDataExtent delay problem

Greg Allensworth
> to load a base WMS layer and a KML file on it. The problem is that I
> want to display the map just arround the bounding box of the KML file
> but the method getDataExtent only returns something usefull when the
> method has returned. Some ideias ?

Yep. The Vector layer loading is asynchronous; at the time you add the
layer to the map, the data isn't ready. So, have the Layer catch the
"loadend" event, and have it respond to its freshly-loaded data *after*
it has loaded.

vectorlayer.events.register('loadend', vectorlayer, function () {
    map.zoomToExtent( this.getDataExtent() );
});


--
Greg Allensworth, Web GIS Developer
BS  A+  Network+  Security+  Linux+  Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510  San Francisco CA 94104
PH: 415-979-0343 x302  FX: 415-979-0371    email: [hidden email]
Web: www.GreenInfo.org     www.MapsPortal.org

Subscribe to MapLines, our e-enewsletter, at www.GreenInfo.org
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

OpenLayers UI Library/CMS?

Arnie Shore
In reply to this post by Marcelo-2
Folks, in planning to move our (mostly!) Open Source dispatch
application (Tickets CAD by name) to OpenLayers (thanks to all here who
have replied to this noob's questions) I'm considering an alternative to
our Plan A, this plan consisting of a largely one-for-one replacement of
each of the existing low-level GMaps API function calls.

Our alternative approach, Plan B, wd make use of any popular server-side
CMS or client-side UI libraries that can provide the target OSM/OL
capabilities, along with the second tall-pole-in-our-tent, a data-grid
capability.  JQuery and Drupal come to mind here.

The target implementation wd be made available in two flavors, the first
providing for access to an OSM repository. The second - more oriented to
emergency operations sans Internet availability - wd include
locally-stored tile sets for the areas of user interest.

The application is oriented to meeting data handling needs, rather than
to cartographic requirements.  Our existing application's capabilities
are generally satisfactory, but there's a lot of PHP ad JS that I'd
expect to replace with whatever Plan B provides out-of-the-box.  Data
handling requirements so far are modest; tables of several hundred entries.

The other givens are free, some Open Source license, PHP, and a minimal
number of dependencies.  I've done enough preliminary work with a TMS
directory structure to satisfy myself that a geo-server (for the
non-Internet implementation) wd add un-needed complexity, and I'm ruling
that out.

So, any suggestions, URL's, caveats, experiences, etc. re likely
candidates are solicited.

Thanks again, all.  The help you've provided in the past is gratefully
acknowledged.



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

Experience with GeoExt?

Arnie Shore
I've been scouting for a JS framework or library that combines the
pleasures (!) of OL/OSM with a datagrid function, since these two are at
the heart of an app we're looking to port from GMaps to open source.

See http://www.geoext.org/

I wonder if anyone here has some experience to speak to on this package,
or alternatives to suggest.  Our application is data intensive -
conventional stuff mostly, with a smidgin of geo-data.  Important, but
just a smidgen nevertheless.

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

Re: Experience with GeoExt?

Phil Scadden
I make pretty heavy use of some of the widgets. The layertreebuilder ux
especially. One issue though - conversion to Ext 4 is not trivial and I
dont think it has begun.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

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

Re: Experience with GeoExt?

alexander-petkov
In reply to this post by Arnie Shore
Geoext is pretty easy to use, well documented with lots of examples.

Alex

On Mon, Jul 25, 2011 at 6:23 PM, Arnie Shore <[hidden email]> wrote:

> I've been scouting for a JS framework or library that combines the pleasures
> (!) of OL/OSM with a datagrid function, since these two are at the heart of
> an app we're looking to port from GMaps to open source.
>
> See http://www.geoext.org/
>
> I wonder if anyone here has some experience to speak to on this package, or
> alternatives to suggest.  Our application is data intensive - conventional
> stuff mostly, with a smidgin of geo-data.  Important, but just a smidgen
> nevertheless.
>
> AS
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

LayerSwitcher Control Events?

Arnie Shore
In reply to this post by Phil Scadden
I'd like to intercept any click on subject control (to do some sidebar
manipulation).  What events are available?  Thanks, all.

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

Re: LayerSwitcher Control Events?

Jean-François Gigand-2
Hi,

What is "subject control" ?

Anyway, the list of available events for every object class is in the
EVENT_TYPES property, and also documented in the API.

Check out: http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers-js.html
Or the source code, which is straightforward.

Best regards,

Jean-François Gigand - Geonef
Paris, France - http://geonef.fr/



2011/8/14 Arnie Shore <[hidden email]>:
> I'd like to intercept any click on subject control (to do some sidebar
> manipulation).  What events are available?  Thanks, all.
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users