【发布时间】:2023-03-04 03:20:01
【问题描述】:
我正在尝试使用 MapServer 制作一张图像,它只显示一个带有标签的图层。我写了以下地图文件:
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
我正在使用 PHP 和 ms_newMapObjFromString() 生成图像。但是,我得到的只是一张没有任何文字的透明图像。我错过了什么?
编辑: PHP代码:
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 是上面贴出的字符串。
【问题讨论】: