[mapserver-users] openlayers 3

Jeff McKenna jmckenna at gatewaygeomatics.com
Mon May 16 08:50:38 PDT 2016


Hello Hosain,

To help you and others get started with OpenLayers, I've added an 
OpenLayers 3 example that uses a (local) WMS service, into MS4W's 
OpenLayers package.  The data is in spatialite format.  What's nice is 
that you can just use this working mapfile (that lives in 
/ms4w/apps/openlayers/examples/map/wms-server.map) and its working 
javascript code (visible through a link on the MS4W homepage at 
127.0.0.1).  Once you install MS4W 3.14 and the OpenLayers 3.15.1 
package (from http://ms4w.com), look for a new "MapServer WMS Example" 
on your MS4W homepage, under the "OpenLayers" section.  This new demo 
will look like this:  http://pasteboard.co/Y63Qzix.jpg

If you use MS4W's setup.exe installer the mapfile and the OpenLayers 
code will be automatically modified for your installation (path to 
mapfile, WMS onlineresource, Apache port, etc.).

I think this will help you and others get started with OpenLayers3 and MS4W.

-jeff


-- 
Jeff McKenna
MapServer Consulting and Training Services
http://www.gatewaygeomatics.com/




On 2016-05-16 4:29 AM, Yves Jacolin wrote:
> Hello,
>
> It could be two kind of problem:
> * server side
> * client site
>
> It is difficult to see a problem (except obvious one) in such code. Did you
> check that your mapserver is working correctly?
>
> If not check this:
> http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/jask/jask.map&REQUEST=getcapabilities&SERVICE=WMS&VERSION=1.3.0
>
> If you get the capabilities, check any errors messages in the capabilities. If
> you can't have the capabitilies, try to find the error or post the error
> message if you can't find it.
>
> When WMS service works, you can try the ol3 mailing list to see why the client
> side is not working.
>
> Regards,
>
> Y.
>
> On Friday, May 13, 2016 11:54:55 hosain mohammadi wrote:
>> hello
>>
>> i'd like to use openlayers3 for wms service
>> the belowe code is correct?
>>
>> <!doctype html>
>> <html lang="en">
>>   <head>
>>     <link rel="stylesheet"
>> href="http://openlayers.org/en/v3.15.1/css/ol.css" type="text/css">
>>     <style>
>>       .map {
>>         height: 100%;
>>         width: 100%;
>>       }
>>     </style>
>>     <script src="http://openlayers.org/en/v3.15.1/build/ol.js"
>> type="text/javascript"></script>
>>     <title>web gis</title>
>>   </head>
>>   <body>
>>
>>     <div id="map"></div>
>>     <script type="text/javascript">
>>
>>     var layers = [
>>           new ol.layer.Image({
>>             extent: [1062293,17704892,1085747,17720997],
>>             source: new ol.source.ImageWMS({
>>               url: '
>> http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/jask/jask.map
>> ',
>>               params: {
>>                 'LAYERS': 'jask',
>>                 'CRS': 'EPSG:4326',
>>                 'BBOX': '1062293,17704862,1085747,17720997',
>>                 'FORMAT': 'image/png',
>>                 'mode':'map'
>>               },
>>               serverType: 'mapserver'
>>             })
>>           })
>>         ];
>>     var projection = new ol.proj.Projection({
>>      code: 'EPSG:4326',
>>      units: 'm'
>>      });
>>
>>         var map = new ol.Map({
>>           layers: layers,
>>           target: 'map',
>>           controls: [
>>               new ol.control.Zoom(),
>>               new ol.control.ZoomSlider()
>>           ],
>>
>>           view: new ol.View({
>>             center: [1073136.94,17716190.89],
>>             zoom: 13,
>>             projection: projection
>>           })
>>         });
>>
>>
>>
>>     </script>
>>   </body>
>> </html>
>>
>>
>>
>> someone has offer?
>





More information about the mapserver-users mailing list