惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 独孤求败

移动端跨平台框架及资料 清理数据库订阅表 Raphael JS 矢量客户端开源框架 基于SqlServer 2008 Service Broker的分布式应用 Telerik在mvc中的环境搭建 openscales2.2 style定义 openscales2.2 tilecache2.11图片缓存 openscales2.2 的初始缩放等级 openscales2.2的画点、线、多边形 Vs2010 FLex的集成开发 PostGis Mapserver Openscales 环境搭建 mvc3无智能提示的解决方法 oracle数据库管理员创建用户的job 隐藏后台执行的dos窗口 iframe 加载完成但是ie进度条还在加载的解决办法 安卓模拟器的安装和使用 WCF错误及处理记录 - 独孤求败 - 博客园 .net学习资料链接收集整理 B树、B-树、B+树、B*树
Openscales2.2 mapserver 开发demo
独孤求败 · 2013-03-28 · via 博客园 - 独孤求败

很简单的一个地图demo,使用wms画线,请求wfs画点( 其他的就不详述了,已经有很多文档了)。

map文件如下:

View Code

map
  NAME "OpenscalesDemo"
  SIZE 400 300
  IMAGECOLOR 242 232 106
  IMAGETYPE PNG
  STATUS ON
  EXTENT -180 -90 180 90

  PROJECTION
     "init=epsg:4269"
  END

  SYMBOL
    NAME 'circle'
    TYPE ELLIPSE
    FILLED TRUE
    POINTS
      1 1
    END
  END

    WEB
       TEMPLATE  "D:/tmp/test.html"
       IMAGEPATH "D:/tmp/"   #文件写在这里
       IMAGEURL "D:/tmp/"    #读取的时候读这里
       METADATA
         "wfs_srs"            "EPSG:4326 EPSG:4269" 
         "wfs_enable_request" "*"
         "wms_enable_request" "*"
         "wms_srs"            "EPSG:4326 EPSG:4269 " 
       END
    END


    LAYER
      NAME line_track
      TYPE LINE
      FEATURE
        POINTS
          0 0 
          10 10 
          72.36 33.82
          70.85 34.32
          69.43 35.15
          70.82 36.08
          70.90 37.05
          71.21 37.95
          100.0 56.0
          300   300
          100   100 
          -100   -100
          -300  -300
        END
      END
      CLASS
        STYLE
          COLOR 251 13 0
          SIZE 3
        END
      END
    END

    LAYER
         name "pointtop_track"
         TYPE point
        FEATURE
           POINTS 
              -100 -100
           END
        END
        CLASS
          STYLE
           SYMBOL 'circle'
           COLOR 13 58 179
           SIZE 8
           WIDTH 5
          END
          LABEL 
            COLOR 255 13 0 
            SIZE SMALL 
          END
      END # end class
    END # end layer


    LAYER
        name "pointend_track"
        TYPE point
        FEATURE
           POINTS 
              100 100
           END
        END
        CLASS
          STYLE
           SYMBOL 'circle'
           COLOR 13 58 179
           SIZE 8
           WIDTH 5
          END
          LABEL 
            COLOR 255 13 0 
            SIZE SMALL 
          END
        END # end class
    END # end layer

END # end mapfile

 TEMPLATE就不在这里罗列了,参见mapserver官网有现成的。

Flex 代码如下:

View Code

<?xml version="1.0" encoding="utf-8"?>
<s:Application
          xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx"
          width="100%"
          height="100%"
          xmlns:os="http://openscales.org"
          creationComplete="initMap()" >

    <os:Map id="fxMap" width="100%" height="100%" center="67,-80"
         maxExtent="-180,-90,180,90" projection="EPSG:4326">

        <os:WMSC name="line_track"
          url="http://localhost:8085/cgi-bin/mapserv.exe?MAP=D:/tmp/GisDemo/GisDemo/Content/map/OpenscalesDemo.map"
          layers="line_track"
          format="image/jpeg"
          maxExtent="-180,-90,180,90"
          />
          
        <os:WFS
          name="line_track"
          url="http://localhost:8085/cgi-bin/mapserv.exe?MAP=D:/tmp/GisDemo/GisDemo/Content/map/OpenscalesDemo.map"
          typename ="pointtop_track"
          version="1.0.0"
          useCapabilities="false"
          style="{Style.getDefaultPointStyle()}"
            />

        <os:WFS
            name="pointtop_track"
            url="http://localhost:8085/cgi-bin/mapserv.exe?MAP=D:/tmp/GisDemo/GisDemo/Content/map/OpenscalesDemo.map"
            typename ="pointend_track"
            version="1.0.0"
            useCapabilities="false"
            style="{Style.getDefaultPointStyle()}"
        />

        <!-- 比例尺 -->
        <os:ScaleLine x="{10}" y="{height-80}" />
        <!-- 显示鼠标坐标 -->
        <os:MousePosition x="{fxMap.width / 2}"
              y="{fxMap.height-20}"
              displayProjection="EPSG:4326"/>
        <!-- 导航控件1 -->
        <os:PanZoom map="{map}"
           x="{fxMap.x+10}"
           y="{fxMap.y+10}" width="112" height="126"/>

    </os:Map>

    <fx:Script>
        <![CDATA[
        import org.openscales.core.Map;
        import org.openscales.fx.feature.*;
        import  org.openscales.core.feature.*;
        import mx.printing.PrintAdvancedDataGrid;
        import org.openscales.fx.layer.FxWFS;
        import org.openscales.core.style.Style;
    
        //private var popup:Anchored
        [Bindable]private var map:Map;
        
        public  function initMap():void {
            map = fxMap.map;
            
        }
]]>
    </fx:Script>

</s:Application>

在vs2010中增加openscales包的方法如下:

   鼠标右键你创建的flex工程,如下图:

 选择下载的openscales的开发包目录即可。

 在实际调用地图的过程中,可能会有跨域访问的问题,在你的地图服务(即Apache)下面增加一下xml文件:crossdomain.xml,内容如下:

<?xml version="1.0"?>   
<cross-domain-policy>   
 <allow-access-from domain="*" />   
</cross-domain-policy>  

 地图运行效果如下: