[mapguide-users] WFS Connection from OpenLayers

RDBauer rdbauer at gmail.com
Fri Jun 14 05:37:57 PDT 2013


All,

I have searched the list and Google and have not been able to find what I
need. I am trying to connect to MapGuide (2.5 on test machine but 2.2 on
production machine right now) from OpenLayers 2.12. I know that it would be
easier to use Fusion, but it currently doesn't have the support for Mobile
and that is what I need. Also, I can't use PHP or .NET for any code because
it will be packaged in PhoneGap for a mobile app. Right now I am just trying
to connect to the sample dataset to get things working and also, by actual
data will most likely be served as the same WGS projection. My current code
is:


/map = new OpenLayers.Map({
        div: "map",
        theme: null,
        projection: osmProj,
        displayProjection: wgs,
        maxExtent: extent,
        scales: tempScales,
        controls: [
            new OpenLayers.Control.Attribution(),
            new OpenLayers.Control.TouchNavigation({ dragPanOptions: {
enableKinetic: true } }),
            //new
OpenLayers.Control.Scale(document.getElementById("mapScale"))
        geolocate
        //selectControl
        ]
    });

var layer = new OpenLayers.Layer.MapGuide("Sheboygan Tiled Layer", url,
params, options);

var wfsParcels = new OpenLayers.Layer.Vector("WFS Parcels", {
        strategies: [new OpenLayers.Strategy.Fixed()],
        protocol: new OpenLayers.Protocol.WFS({
            //version: "1.1.0",
            srsName: "EPSG:4326",
            url:
"http://localhost/mapguide/mapagent/mapagent.fcgi?USERNAME=Administrator&Password=admin",
            featureType: "ns34414117:ParcelsType",
            featureNS: "http://www.opengis.net/gml",
            geometryName: "SHPGEOM"
        }), 
        styleMap: new OpenLayers.StyleMap({
            strokeWidth: 3,
            strokeColor: "#333333"
        })
        //projection: wgs
    });

map.addLayer(layer);
map.addLayer(wfsParcels);
map.zoomToExtent(extent);/

With this current code, I get the following error in Chrome Developer Tools:

/Failed to load resource: Origin null is not allowed by
Access-Control-Allow-Origin.
http://localhost/mapguide/mapagent/mapagent.fcgi?USERNAME=Administrator&Password=admin

XMLHttpRequest cannot load
http://localhost/mapguide/mapagent/mapagent.fcgi?USERNAME=Administrator&Password=admin.
Origin null is not allowed by Access-Control-Allow-Origin. index.html:1/

Things I am not sure about if they are correct are the "featureType" &
"featureNS". I got those from the GETCAPABILITIES command. Any thoughts?

Thanks,
Rich



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WFS-Connection-from-OpenLayers-tp5060185.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list