mapserver+postgis(postgresql) +openlayers发布地图成功

前端之家收集整理的这篇文章主要介绍了mapserver+postgis(postgresql) +openlayers发布地图成功前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1. 在windows xp上成功

先来个结果图


渲染很慢,本机都很慢,必须做缓存,下一步用tilecache把切片加进去


2. tilecache.cfg的配置添加如下:

[railway]
type=WMS
url=http://localhost:8080/cgi-bin/xmap.exe
layers=bou2_4p.the_geom,chinaMapL,railway,river,roadExceptSCCQ,roadSCCQ,shengjieline,xianjieline,dijishipoint,provincealcapital,xianpoint
extension=jpeg
size=256,256
bBox=63.579528,12.379029,158.398491,70.273782
#resolutions=110,90,70,50,30,25,20,4

openlayers的调用如下:

var options = {
@H_301_29@controls : [
@H_301_29@ new OpenLayers.Control.Navigation(),
@H_301_29@//new OpenLayers.Control.KeyboardDefaults(),
@H_301_29@// new OpenLayers.Control.Scale(),
@H_301_29@new OpenLayers.Control.MousePosition({
@H_301_29@formatOutput:_this.MousePositionFormatOutput
@H_301_29@}),
@H_301_29@new OpenLayers.Control.LayerSwitcher(),
@H_301_29@new OpenLayers.Control.PanZoomBar() ],
@H_301_29@projection : new OpenLayers.Projection("EPSG:4326"),
@H_301_29@//displayProjection : new OpenLayers.Projection("EPSG:4326"),
@H_301_29@units : "dd",
@H_301_29@//maxResolution: "auto",
@H_301_29@maxResolution: 0.18519328710937499,
@H_301_29@//minResolution: 0.29858214168548586,
@H_301_29@maxExtent: new OpenLayers.Bounds(63.579528,70.273782)//20037508.34,238107693.23182


@H_301_29@};
@H_301_29@map = new OpenLayers.Map('map',options);

var railwaylayer = new OpenLayers.Layer.WMS("railway","http://localhost:8080/tilecache/tilecache.py?",{ layers: 'railway',format: 'image/png' });
@H_301_29@map.addLayer(railwaylayer);

可以显示出地图,但是没有缓存出瓦片,tmd


但是

[basic]
type=WMS
url=http://labs.Metacarta.com/wms/vmap0
extension=png

@H_301_29@projection : new OpenLayers.Projection("EPSG:4326"), @H_301_29@
@H_301_29@units : "dd",
@H_301_29@maxResolution: 360 / 512, @H_301_29@
@H_301_29@maxExtent: new OpenLayers.Bounds(-180,-90,180,90)

var layer = new OpenLayers.Layer.WMS("basic",{ layers: 'basic',format: 'image/png' });
@H_301_29@

这个可以成功,不过要注意地图的optntion,注意是分辨率要对应。

3. mapserver,地图label显示中文

首先设置字体,在fontset.txt 文件中设置如下:

simhei Fonts\simhei.ttf
arial Fonts\arial.ttf
simfang Fonts\simfang.ttf
simkai Fonts\simkai.ttf

其实就是为tt.map中的label标签设置字体对应的字体文件,如下

LABEL
FONT simfang
TYPE truetype
SIZE 10
COLOR 0 0 0
ANGLE 0
POSITION cc
FORCE true
ANTIALIAS true
PARTIALS true
END

显示中文如下:


4. 下一步,一定要实现mapserver发布本机的postGIS数据,用tilecache实现自动缓存,如果有知道的朋友,请留言指导,谢谢。

原文链接:https://www.f2er.com/postgresql/196830.html

猜你在找的Postgre SQL相关文章