The images show up red because the request didn't result in a valid map image.
This is how you debug such a problem:
- Open the page in FireFox or Chrome.
- Then save one of the red images to disk.
- Open the saved file in a text editor.
Now, it looks like you are not requesting images, but you are requesting the capabilities of the server.
You've probably pasted the server URL into your code, but you've pasted the URL that requests what the server can do, and what it supports.
So, just remove this part from the URL:
request=GetCapabilities
So that it becomes: http://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer?service=WMS
Save the HTML, and refresh.
Ok, we're now actually requesting images, but you're still not getting anything.
So, do the same. Save one of the red images, and see what's inside.
This time there's an error message inside:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<!DOCTYPE ServiceExceptionReport SYSTEM "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd">
<ServiceExceptionReport version="1.1.1">
<ServiceException code="LayerNotDefined">
Parameter 'layer(s)' contains unacceptable value: States
</ServiceException>
</ServiceExceptionReport>
Looks like you're requesting a layer called States
, but that layer does not exist.
Just provide a valid layer and you should be done. It looks like there are 2 layers on the server, called "1" and "2". When you set that as the layer, the red images are gone, but they don't seem to contain anything interesting, but that's yet another problem that i cannot help you with, unless I get more information.