<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

    <style type="text/css">
        body {
            margin: 1em;
        }
        #map {
            width: 400px;
            height: 400px;
            border: 1px solid black;
        }
    </style>
    <!--<script src="../openlayers/OpenLayers.js"></script>-->
        <script src="http://openlayers.org/api/2.8/OpenLayers.js"></script>

    <script type="text/javascript">
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 3;

        var map;
        //var serverWMS = "http://demo.opengeo.org/geoserver/wms";
        var serverWMS = "http://localhost:8080/geoserver/wms";
        var serverWFS = "http://localhost:8080/geoserver/wfs";
                
                var styleMapLabelDS;
 
                function set_styleMapLabelDS()
                {
                        var template = {
                                strokeColor: "#0000FF",
                                strokeOpacity: 1,
                                strokeWidth: 3,
                                fillColor: "#00AAFF",
                                fillOpacity: 1,
                                pointRadius: 5,
                                pointerEvents: "visiblePainted",
                 
                                //label : "${ADMIN_NAME}",
                                label : "${CITY_NAME}",
                 
                                labelOffsetX: "10",
                                labelOffsetY: "-10",
                                fontColor: "red",
                                fontSize: 10,
                                fontFamily: "Arial",
                                fontWeight: "bold",
                                labelAlign: "lt"
                        };
                        var templateB = {
                                strokeColor: "#FF00FF",
                                strokeOpacity: 1,
                                strokeWidth: 3,
                                fillColor: "#AA00FF",
                                fillOpacity: 1,
                                pointRadius: 5,
                                pointerEvents: "visiblePainted",
                 
                                //label : "${ADMIN_NAME}",
                                label : "${CITY_NAME}",
                 
                                labelOffsetX: "10",
                                labelOffsetY: "-10",
                                fontColor: "blue",
                                fontSize: 10,
                                fontFamily: "Arial",
                                fontWeight: "bold",
                                labelAlign: "lt"
                        };
                        styleMapLabelDS = new OpenLayers.StyleMap( { "default" : new OpenLayers.Style(template), "select" : new OpenLayers.Style(templateB) } );
                }
                 

                
        function init(){
                        
                        var bounds = new OpenLayers.Bounds(
                                144, -44,
                                149, -40
                        );
                        var options = {
                                //controls: [],
                                maxExtent: bounds,
                                maxResolution: 0.0132147812500001,
                                projection: "EPSG:4326",
                                units: 'degrees'
                        };

                        map = new OpenLayers.Map('map', options);

                        var base = new OpenLayers.Layer.WMS(
                                "Tasmania", 
                                serverWMS,
                                {
                                        layers: 'topp:tasmania_state_boundaries',
                                        srs: 'EPSG:4326',
                                        format: 'image/png'
                                }
                            );
                        
                        var wfs = new OpenLayers.Layer.WFS(
                                "Cities",
                                serverWFS,
                                {
                                        typename: 'topp:tasmania_cities',
                                        srs: 'EPSG:82176'
                                }
                        );
                        
                        set_styleMapLabelDS();
                        wfs["styleMap"]=styleMapLabelDS;
                        wfs.redraw();
                        
                            map.addLayers([base, wfs]);

                        map.addControl(new OpenLayers.Control.Navigation());
                            map.addControl(new OpenLayers.Control.LayerSwitcher());

                        map.zoomToMaxExtent();
                        
        }

    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
  </body>
</html>