【问题标题】:postgres db in mapserver getting not found http://localhost/cgi-bin/LAYER157439308110272.png找不到地图服务器中的 postgres db http://localhost/cgi-bin/LAYER157439308110272.png
【发布时间】:2019-11-22 03:36:49
【问题描述】:

代码LAYER.map文件Layer.map文件

    MAP
    NAME "LAYER"
    SIZE 400 400
    STATUS ON
    EXTENT 1143759 4417539 1146436 4420390
    UNITS METERS 

    WEB
    TEMPLATE "template.html"
    END

    LAYER
         CONNECTIONTYPE Postgis
            CONNECTION "host=localhost dbname=newmapserver user=postgres password=**** port=5432"
            DATA "geom FROM song"
        NAME "song"
        TYPE POLYGON
        STATUS ON
        CLASS
          STYLE
            COLOR 255 235 190
            OUTLINECOLOR 0 0 0
            SYMBOL 0
          END
        END
    END

   END

示例文件 sample.html 示例.html 文件

<html>
<head><title>Creating a simple image using Mapserver and a Shapefile</title></head>
<body bgcolor="#FFFFFF">
<h2>Creating a simple image using Mapserver and a Shapefile</h2>
<p><hr><p>
This page simply contains a link which sends a set of instructions to the Mapserver application using a mapfile.<br />
The information stored within the mapfile tells the Mapserver application how to draw the map.<p>
<!-- The following link sends the local file structure path of the mapfile to the web location of the mapserver executable file  -->
<A HREF="http://localhost/cgi-bin/mapserv.exe?map=C:\ms4w\Apache\htdocs\LAYER.map">
Click on this link</A> to view a map generated using a Shapefile.
<p><hr><p>

</body>
</html>

template.html 文件 模板文件

<!-- MapServer Template -->
<html>
<head><title>Simple Mapserver Template HTML Document</title></head>
<body bgcolor=#AAAAAA>
<h2>The image below was illustrated based on the instructions sent in the mapfile.</h2>
<!-- When using Mapserver with a template, the Mapserver application looks for the [img] tag within the template document to place the map -->
<IMG SRC="[img]" width=400 height=300 border=0>
</body>
</html>

当我运行 sample.html 文件并单击链接查看时,我得到了 image not found 错误 在控制台中找不到http://localhost/cgi-bin/LAYER157439308110272.png

【问题讨论】:

    标签: javascript html postgresql mapserver


    【解决方案1】:

    您的查询模板文件结构不正确。它应该看起来像这样(列出数据库表中所需的每一列):

    <!-- MapServer Template -->
            <tr>
              <td>[name]</td>
              <td>[description]</td>
            </tr>
    

    您应该从 LAYER 内部指向该模板文件,例如:

            LAYER 
              ...
              CLASS
                ...
                TEMPLATE "template.html"
                ...
              END  # CLASS
    
            END  # layer
    

    我建议查看 MapServer 教程第 3.1 节中的完整工作示例:https://demo.mapserver.org/tutorial/section3.html

    【讨论】:

      猜你喜欢
      • 2017-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-24
      • 1970-01-01
      • 2014-03-05
      • 1970-01-01
      • 2014-03-18
      相关资源
      最近更新 更多