Issues with OpenLayers and Sharp WMS Server

Topics: SharpMap v0.9 / v1.x
Sep 24, 2008 at 7:40 PM
I am trying to use OpenLayers to overlay Google Maps and some layers within a PostGIS database. Instead of using Geoserver I am trying to use Sharpmap as a WMS server. Problem is I can't get them to overlay properly. I have tried many projections and they just will not overlay properly.

Am I missing something.
Sep 24, 2008 at 7:57 PM
how deep is blue?$0.$0$0.$0$0.$0$0.$0$0.$0$0show us some code!!!$0
Sep 24, 2008 at 8:05 PM

I have tried numerous EPSG's 900913, 3395, 4326 and several others.

Here is the Javascript

      mapExtent[0] = -93
      mapExtent[1] = 47
      mapExtent[2] = -86
      mapExtent[3] = 42
        function createLayers(){
         // create Google layer
            gnormal = new OpenLayers.Layer.Google(
                "Google Map",
                {MIN_ZOOM_LEVEL: 2, MAX_ZOOM_LEVEL: 17, type: G_NORMAL_MAP, 'sphericalMercator': false}
                    // create Google layer
            gsat = new OpenLayers.Layer.Google(
                "Google Satellite Map",
                {MIN_ZOOM_LEVEL: 2, MAX_ZOOM_LEVEL: 17, type: G_SATELLITE_MAP, 'sphericalMercator': false}
        function init(){

            var options = {
                // the "community" epsg code for spherical mercator
                projection: "EPSG:900913",
                // map horizontal units are meters
                units: "dd",
                minExtent: "auto",       
            controls: []
            map = new OpenLayers.Map('map', options);
                 // create OSM layer
        var wmsLayer = new OpenLayers.Layer.WMS( "WmsLayer", "",
            {layers: "Counties",
            format: "image/jpeg", request: "GetMap", CRS: "EPSG:900913",
            BGCOLOR: "0XF5F1E6",

            version: "1.3.0"}, {isBaseLayer: false, opacity: 0.6, 'displayOutsideMaxExtent': true});
          map.addLayers([wmsLayer, gnormal ]);

            var usBounds = new OpenLayers.Bounds(
                mapExtent[0], mapExtent[1], mapExtent[2], mapExtent[3]);        
         var controlID = new OpenLayers.Control.Identify(myIdentify);

.NET code
Public Class MapHelper
    Public Shared Function InitializeMap(ByVal size As System.Drawing.Size) As SharpMap.Map
        HttpContext.Current.Trace.Write("Initializing map...")

        'Initialize a new map of size 'imagesize'
        Dim map As New SharpMap.Map(size)
        'Dim map As SharpMap.Map = New SharpMap.Map(Size)
        Dim ConnStr As String = "server=test;database=pg_apl2;User Id=pgisuser_;password=test"

        Dim dtcounties As New SharpMap.Data.Providers.PostGIS(ConnStr, "redistrict_counties", "the_geom", "gist_id")
        'Dim dtmcds As New SharpMap.Data.Providers.PostGIS(ConnStr, "mcd_redist", "the_geom", "gist_id")
        'Dim dtclinics As New SharpMap.Data.Providers.PostGIS(ConnStr, "clinics", "the_geom", "gist_id")

        Dim lyrCounties As SharpMap.Layers.VectorLayer = New SharpMap.Layers.VectorLayer("Counties")

        'dtclinics.DefinitionQuery = " clinic_cod = 12100"
        With lyrCounties
            .DataSource = dtcounties
            .Style.Fill = Brushes.Aquamarine
            .Style.Outline = System.Drawing.Pens.Black
            .Style.EnableOutline = True
        End With

        'Dim layWms As SharpMap.Layers.WmsLayer = GetWmsLayer2()


        HttpContext.Current.Trace.Write("Map initialized")

        Return map

    End Function
Sep 25, 2008 at 6:33 AM
>mapExtent[0] = -93$0>mapExtent[1] = 47$0>mapExtent[2] = -86$0>mapExtent[3] = 42$0Looks 4326 coordinates and not 900913 coordinates$0$0>CRS: "EPSG:900913",$0$0$0I'm not sure this sintax is OK (try with SRS or chech OL docs)$0$0$0$0$0In .net code you need to specify STRS layer, via layer.SRS property.$0