You're going to have to write both pieces of information to your GML. FYI,
the information as to what kind of server you have is misleading and
extraneous. Multiple servers support php, so you didn't really tell us
anything useful. Also, this list is for the client side of things. If you
need help on the server side you're going to have to look elsewhere. But it
basically boils down to that you need to write the info you want into the
GML server side, then write code for the labels and popups in your JS.

Labels: you'll need to write the point labels to your GML, then write a
stylemap to pull out the name.
// Styling for cities
var styleMap = new OpenLayers.StyleMap
(
{
 'default': OpenLayers.Util.applyDefaults(
{
label: '${getName}',
   strokeWidth:1,
   strokeColor:"#CCCCCC",
   fillColor: "green",
   fontSize: "12px",
   fontColor: "grey",
   fontFamily: "Arial",
   labelAlign: "rt",
},
OpenLayers.Feature.Vector.style["default"])

,"select":OpenLayers.Util.applyDefaults({},OpenLayers.Feature.Vector.style["select"])
});
 styleMap.styles["default"].context={getName: labelFunction};

 var cities = new OpenLayers.Layer.GML ("7th Century Cities",
"data/cities.gml",
{
styleMap: styleMap,
projection: new OpenLayers.Projection("EPSG:4326"),
format: OpenLayers.Format.GML
}
);
map.addLayer(cities);
addLayerArchaeological('');
Re: popups.
Write the fields you want to display your GML from what ever database your
using. then the popups are easy. Write the info you want to display as nodes
within your GML, and then see the highlighted text for how to pull it out
into the pop-up.

//Popups
function onPopupClose(evt) {
            selectControl.unselect(selectedFeature);
        }
function onFeatureSelect(evt) {
            selectedFeature = evt.feature;
            popup = new OpenLayers.Popup.FramedCloud("chicken",

evt.feature.geometry.getBounds().getCenterLonLat(),
                                     null,
                                     "<div style='font-size:.8em'>Site_ID: "
+ evt.feature.attributes.SITE_ +"<hr />Locality: " +
evt.feature.attributes.location1+"<br/>Presence: "
+evt.feature.attributes.PRESENCE_A+"<br/> Material:
"+evt.feature.attributes.MATERIAL+"</div>",
                                     null, true, onPopupClose);
            evt.feature.popup = popup;
            map.addPopup(popup);
        }
  function onFeatureUnselect(evt) {
            map.removePopup(evt.feature.popup);
            evt.feature.popup.destroy();
            evt.feature.popup = null;
        }

On Mon, Nov 22, 2010 at 9:47 AM, pawprint_net <[email protected]> wrote:

>
> In short: How do you get attribute data (easiest way) from a server (php in
> my case) to a vector layer.
>
> I'm trying to set up what I believe is a fairly straightforward system but
> can't see how to make it work, checked docs, and many examples but it's
> just
> not doing what I need. I could well be doing something wrong with name
> spaces and the like really not sure about that.
>
> Desired End Result: A map with point features from my custom-built php
> server that has labels with the name of the feature. I have complete
> control
> over the client side and the server side of this one (looking for the
> simplest way to do this) - at some point in the future I'd like to extend
> this to read additional attribute data to display a pop-up on click and
> perhaps also show things other then just points - but for now I'm just
> trying to get this to work.
>
> Here is what my server is putting out (can easily be changed):
>
> <wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs";
>                    xmlns:xde="http://www.example.com/myns";
>                    xmlns:gml="http://www.opengis.net/gml";
>                    xmlns:ogc="http://www.opengis.net/ogc";
>                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
>                    xsi:schemaLocation="http://www.opengis.net/wfs
> http://schemas.opengeospatial.net//wfs/1.0.0/WFS-basic.xsd";>
> <gml:boundedBy>
> <gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326";>
> <gml:coordinates decimal="." cs="," ts=" ">
>
>
> -124.58021460938,48.783354492188,-122.93226539062,50.156645507812
>
> </gml:coordinates>
> </gml:Box>
> </gml:boundedBy>
> <gml:featureMember>
> <xde:asset fid="asset.71">
> <xde:name>Alberni Responder</xde:name>
> <xde:geometry>
> <gml:Point srsName="http://www.opengis.net/gml/srs/epsg.xml#4326";>
> <gml:coordinates>-124.812,49.2443</gml:coordinates>
> </gml:Point>
> </xde:geometry>
> </xde:asset>
> </gml:featureMember>
>
> etc...
> </wfs:FeatureCollection>
>
>
> And here is my OL config:
>
>
> function init(){
>            var lat = 49.47;
>            var lon = -123.75624
>            OpenLayers.IMAGE_RELOAD_ATTEMPTS = 4;
>            OpenLayers.Util.onImageLoadErrorColor = "transparent";
>            options = {resolutions:[1.40625, 0.3515625, 0.087890625,
> 0.02197265625, 0.0054931640625, 0.00274658203125, 0.001373291015625,
> 0.0006866455078125, 0.00034332275390625, 0.000171661376953125,
> 8.58306884765625e-05, 4.291534423828125e-05],
>                       projection:"EPSG:4326",
>                       controls: []};
>            map = new OpenLayers.Map( 'map',options );
>            layer = new OpenLayers.Layer.WMS( <approperiate layer options
> here - this works fine>);
>
>            mywfs = new OpenLayers.Layer.Vector("Features", {
>                    strategies: [new OpenLayers.Strategy.BBOX()],
>                    styleMap: new OpenLayers.StyleMap({fillColor: "#ff0000",
>                                                       strokeColor:
> "#990000",
>                                                       strokeWidth: 1,
>                                                       fillOpacity: 0.9,
>                                                       pointRadius: 5,
>                                                       label: "${name}"
>                                                      }),
>                    protocol: new OpenLayers.Protocol.HTTP({url:
> "http://<path to my php here>",
>                                                            params: {
>                                                                format:
> "WFS",
>                                                                service:
> "assets",
>                                                                request:
> "GetFeatures",
>                                                                srs:
> "EPSG:4326",
>                                                                maxfeatures:
> 50
>                                                            },
>                                                            format: new
> OpenLayers.Format.GML({featurePrefix:'xde',
>
> featureName: 'xde:asset',
>
> extractAttributes: true}),
>                                                        })
>                });
>            map.addLayers([layer,mywfs]);
>
>
> The resulting map shows the features but no labels and seems to completely
> disregard my attempt to style them. If anyone can see what I'm doing wrong,
> point me to a similar example, or suggest a better method I'd be very
> appreciative.
>
> -----
> Fair Winds, and watch for squalls from leeward
> --
> View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/Please-Help-Text-Labels-Atribute-data-from-WFS-HTTP-tp5763105p5763105.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Nicholas Efremov-Kendall
Dept. of Anthropology
Washington University in St. Louis
Campus Box 1114
St. Louis, MO, 63130
(917) 370-3489
[email protected] <[email protected]>
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to