Select to view content in your preferred language

How to use a WMS Services

1644
3
10-22-2013 10:48 PM
DominikSchlarmann
Deactivated User
Hello,
I've tried to include a WMS Server, which works with this example:
https://developers.arcgis.com/en/javascript/jssamples/layers_wms.html
I also can use WMS Services, which I've published with my owm ArcGIS Server.


But how it's possible to inlcude WMS Services like this:
http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?service=wms&version=1.1.1&request=GetCapabilit...
(Source: http://nowcoast.noaa.gov/help/mapservices.shtml )

As you can see, the URLs are quiete different. Using the second URL, there aren't any information on my map.


Thanks in advance,
Dominik
0 Kudos
3 Replies
by Anonymous User
Not applicable
Original User: betsyjsg

Dominik,
The reason the two urls are so different is that your first url is using a wms service created by ArcGIS Server while your second url is using a wms service that was created using ArcIMS's wmsconnector. The second url is using an older version of Esri software to generate wms services.  Below is code to actually add two layers (NEXRAD radar and surface air temperature locations) from your second url's wms service (NOWCoast) into a map:
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--The viewport meta tag is used to improve the presentation and behavior of the samples 
      on iOS devices-->
    <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
    <title>WMS</title>

    <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/claro/claro.css">
    <link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css">
    
    <script src="http://js.arcgis.com/3.7/"></script>
    <script>
      dojo.require("esri.map");
      var map;

      dojo.ready(function() {
        dojo.declare("my.NOWCoastWMSLayer", esri.layers.DynamicMapServiceLayer, {
          constructor: function() {
            this.initialExtent = this.fullExtent = new esri.geometry.Extent({"xmin":-16476154.32,"ymin":2504688.54,"xmax":-6457400.14,"ymax":7514065.62,"spatialReference":{"wkid":102100}});
            this.spatialReference = new esri.SpatialReference({wkid:102100});

            this.loaded = true;
            this.onLoad(this);
          },

          getImageUrl: function(extent, width, height, callback) {
            var params = {
              request:"GetMap",
              transparent:true,
              format:"image/png",
              bgcolor:"ffffff",
              version:"1.1.1",
              layers:"OBS_MET_TEMP,RAS_RIDGE_NEXRAD",
              styles: "default,default",
              exceptions: "application/vnd.ogc.se_xml",

              //changing values
              bbox:extent.xmin + "," + extent.ymin + "," + extent.xmax + "," + extent.ymax,
              srs: "EPSG:" + extent.spatialReference.wkid,
              width: width,
              height: height
            };
            callback("http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?" + dojo.objectToQuery(params));
          }
        });
      });

      function init() {
        map = new esri.Map("map", {
          basemap: "satellite",
          center: [-103.008, 40.98],
          zoom: 4
        });
        map.addLayer(new my.NOWCoastWMSLayer());
      }

      dojo.ready(init);
    </script>
  </head>
  <body class="claro">
    <div id="map"  style="position:relative; width:1024px; height:512px; border:2px solid #000;"></div>
  </body>
</html>

I've attached a screenshot to show the results.
Hope this helps answer your question.
0 Kudos
RobertBorchert
Honored Contributor
don't know. I am in 10.2 and it worked fine for me.
0 Kudos
by Anonymous User
Not applicable
Original User: Schlomm

Dear Betsy and of course dear all,
Thanks so much. I was able to add my own layer to my map and they're working 🙂
I have another question regarding how to use a Google or OpenLayers Layer.

For my webmap application it would be very useful to include "real time" weather data. I've found two useful services:
http://openweathermap.org/Maps
(Especially the weather stations info)

and the Google Weather Layer:
https://developers.google.com/maps/documentation/javascript/examples/layer-weather?hl=de


I've already tried out to include this in my application, but no success.
You can found an example of my application here:
http://jsbin.com/apAxIhI/1/edit

Maybe someone is willing to include one of the above mentioned layers into the application? Either the layer was not show up or the TOC was not working 😕



Cheerio!
0 Kudos