[OpenLayers-Users] Some help with persistent layers and web server reponses.

Nathan Silver nsilver at imagesensingca.com
Wed Aug 11 12:36:04 EDT 2010


> -----Original Message-----
> From: Eric Lemoine [mailto:eric.lemoine at camptocamp.com]
> Sent: Wednesday, August 11, 2010 12:19 PM
> To: Nathan Silver
> Cc: Users at openlayers.org
> Subject: Re: [OpenLayers-Users] Some help with persistent layers and
> web server reponses.
> 
> On Wednesday, August 11, 2010, Nathan Silver
> <nsilver at imagesensingca.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hello all,
> >
> >
> >
> > I’ve looked at  Peter Robbins’ example of a
> > persistent layer using GeoJSON
> (http://maps.peterrobins.co.uk/files/ol6.html)
> > which is well behaved. I’ve been trying to duplicate the entire
> structure.
> > I have my own IIS 7.5 running on Windows 7 which in turn is connected
> to a SQL
> > Server 2008 DB. Once I can get OpenLayers to send the right query to
> IIS, I’ll
> > be away to the races. Here’s what’s confounding me.
> >
> >
> >
> > The working example issues a GET to retieve the GeoJSON data.
> > The vector layers is defined like this:
> >
> >
> >
> > var vectorLayer = new OpenLayers.Layer.Vector("Line
> > Vectors", {
> >
> > styleMap: sm,
> >
> > eventListeners: {
> >
> >  "featuresadded":
> > dataLoaded
> >
> >  },
> >
> > strategies: [
> >
> > new
> > OpenLayers.Strategy.Fixed(),
> >
> > saveStrategy
> >
> > ],
> >
> > protocol: new OpenLayers.Protocol.HTTP({
> >
> > url:
> > "/cgi-bin/fs/workspace/",
> >
> > format: new
> > OpenLayers.Format.GeoJSON({
> >
> > ignoreExtraDims:
> > true,
> >
> > internalProjection:
> > map.baseLayer.projection,
> >
> > externalProjection:
> > wgs84
> >
> > })
> >
> > })
> >
> > });
> >
> >
> >
> >
> >
> > My code only issues an OPTIONS request to the web server,
> > something the working example never does. If I step through the
> OpenLayers code
> > with Firebug, not only do I not see the OPTIONS request, I don’t see
> anything
> > hitting the webserver at all. My vector layer is defined like this:
> >
> >
> >
> > var vectors = new OpenLayers.Layer.Vector("Vector
> > Layer", {
> >
> > style: {
> >
> > strokeColor:
> > "blue",
> >
> >
> >                 strokeWidth:
> > 3,
> >
> >
> > cursor: "pointer"
> >
> > },
> >
> > eventListeners: {
> >
> > "featuresadded":
> > dataLoaded
> >
> > },
> >
> >                 strategies:
> > [
> >
> >                                 new
> > OpenLayers.Strategy.Fixed(),
> >
> >                                 saveStrategy
> >
> > ],
> >
> >                 protocol:
> > new OpenLayers.Protocol.HTTP({
> >
> >                                 url:
> > "http://10.0.1.26/roads.aspx",
> >
> >
> >
> >                                 format:
> > new OpenLayers.Format.GeoJSON({
> >
> >                                                 ignoreExtraDims:
> > true,
> >
> >                                                 internalProjection:
> > map.baseLayer.projection,
> >
> >                                                 externalProjection:
> > wgs84
> >
> > })
> >
> >  })
> >
> > });
> >
> >
> >
> >
> >
> > If someone can help me understand why OpenLayers is
> > requesting “OPTIONS” from the server (which I can’t even see
> > from grepping  or stepping through the code), and what I might need
> to go
> > in order to get these two piece glued together, I would really
> appreciate it.
> 
> 
> Hi.
> 
> I'm pretty sure you are facing the Same Origin Policy issue. The
> OPTIONS request you're seeing is the "preflighted" request the browser
> sends in your back. See
> <https://developer.mozilla.org/en/HTTP_access_control>. To solve the
> problem the GeoJSON service and the service providing the web page
> must be available at the same domain.
> 
> Cheers,
> 
> 
> --
> Eric Lemoine
> 
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac, Cedex
> 
> Tel : 00 33 4 79 44 44 96
> Mail : eric.lemoine at camptocamp.com
> http://www.camptocamp.com


Hi Eric,

That solved it. I'm now getting the new results POSTed to my web server. I
knew it was something small but very significant.

Thanks for the quick response.
Nathan






More information about the Users mailing list