du2229 2015-03-11 12:54
浏览 73

Mapserver:尝试使用注释/标签制作地图

I'm trying to make an image with MapServer which only displays one layer with a label. I have written the following mapfile:

MAP
    NAME "TextLayer"
    IMAGETYPE PNG
    EXTENT -180 -90 180 90
    IMAGECOLOR 0 0 255
    PROJECTION
        "init=epsg:4269"
    END
    WEB
        METADATA
            "ows_title" "WMS service"
            "ows_onlineresource"    "XXX.XXX.XXX.XXX"
            "ows_enable_request"    "*"
            "ows_crs" "EPSG:4269"
        END
    END
    LAYER
        NAME "labellayer"
        STATUS ON
        TYPE POINT
        FEATURE
            POINTS 100 100 END
            TEXT "The text on the image"
        END
        CLASS
            LABEL
                SIZE 8
                ANTIALIAS true
                COLOR 255 0 0
                POSITION cc
            END
        END
    END
END

I am generating the image with PHP with ms_newMapObjFromString(). However, all I get is a transparent image without any text. What am I missing?

EDIT: PHP Code:

public function PrintImage($request, $mapFileString)
{
    $mapServer_MapObject = ms_newMapObjFromString($mapFileString);

    ms_ioinstallstdouttobuffer();

    $mapServer_MapObject->owsdispatch($request);

    $contenttype = ms_iostripstdoutbuffercontenttype();

    ms_iostripStdoutBufferContentType();

    //If content type is 'image/png' the image is succesfully requested -> show the image
    if($contenttype == "image/png")
    {
        header('Content-type: image/png');

        echo ms_iogetstdoutbufferbytes();
    }
    //Else an error occured -> show the error
    else
    {
        header('Content-type: xml');

        echo ms_iogetstdoutbufferstring();
    }
}

$MapFileString is the string posted above.

  • 写回答

2条回答 默认 最新

  • dousuo8400 2015-03-11 20:32
    关注

    Your map extent does not match the projection you are using. You probably mean the projection EPSG:4326, because -180 -90 180 90 is the maximal extension of this projection.

    Another problem is that your point (POINTS 100 100) is outside the bounding box you request (EXTENT -180 -90 180 90) Try putting the point on the center of the image with

    POINTS 0 0
    

    PS: if it does not work, post your php code as well

    评论

报告相同问题?

悬赏问题

  • ¥15 BV260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序