WP7 ArcGIS 地圖


ArcGIS Runtime SDK for Windows Phone是一套用於構建具有專業GIS功能、大眾地圖服務、LBS相關移動應用的類庫。通過該類庫可將地圖嵌入到您的應用中,加載在線地圖服務,Bing Maps或離線地圖,以完成定位/搜索/空間查詢/數據展示等常見功能;此外,它提供了一系列專業的GIS功能,允許您加載自己的地理數據,進行數據采集/編輯,執行復雜的地理分析任務,從而挖掘數據的潛在價值。

摘自:http://msdn.microsoft.com/zh-cn/windowsphone/partner

准備

SDK下載地址:http://resources.arcgis.com/zh-cn/content/arcgis-api-windows-phone-24-download

幫助文檔http://help.arcgis.com/en/arcgismobile/10.0/apis/windowsphone/help/index.html

這個幫助文檔不得不說一下,很好很強大~~~特別喜歡Sample那一欄

中國數據服務地址 :http://www.arcgisonline.cn/agsolcn/service/map/countrymap2.jsp

中國的地圖數據服務很棒,有各種色調版本,很有愛,哈哈

再一個需要准備的資料是坐標糾偏了,這個~~~~不想多說了,最近看美諜戰劇,一個美特務威脅果戈理說:你要不把東西給我,我就把你的人送到中國監獄,栽贓他危害國家總統~~~果戈里無語了~~,沒有糾偏,阿果連監獄都找不到~~~

基本知識點

  • 基本的地圖加載
<esri:Map x:Name="map" IsLogoVisible="False" Extent="12915510.1474625, 4827746.45379021, 12998675.8823845,4877354.08514722">
    <esri:Map.Layers>
        <local:OfflineArcGISTiledMapServiceLayer ID="StreetMapLayer" Url="http://www.arcgisonline.cn/ArcGIS/rest/services/ChinaOnlineStreetWarm/MapServer"/>
        <esri:GraphicsLayer ID="MyGraphicsLayer" />
    </esri:Map.Layers>
</esri:Map>
 

IsLogoVisible="False" 隱藏Logo,其實ArcGIS的LOGO還是蠻漂亮的,哈

    • 在地圖上添加自定義圖形
      private GraphicsLayer graphicsLayer { get { return mapFeet.Layers["MyGraphicsLayer"] as GraphicsLayer; } }
      private static WebMercator mercator = new WebMercator();
      var myPoint = mercator.FromGeographic(new MapPoint(point.X, point.Y, new SpatialReference(4326)));
      Graphic graphic = new Graphic()
      {
            Geometry = myPoint,
            Symbol = this.Resources["RedMarkerSymbol"] as Symbol
      };
      graphicsLayer.Graphics.Add(graphic);
       

//這個圖形只能是園,方框等,如果其他,只能用圖片

<esriSymbols:PictureMarkerSymbol x:Key="BlueMarkerSymbol" Source="/Images/fuck.png" />

<esriSymbols:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="20" Style="Circle" />

用這個添加元素有個好處,效率高,比在圖層上話UIElement效率要高的多,我搞了200多個fuck.png都很快

  • 地圖緩存

OfflineArcGISTiledMapServiceLayer 是參考菩提老王的博客重寫的一個緩存圖片的Layer

代碼如下:

 public class OfflineArcGISTiledMapServiceLayer : ArcGISTiledMapServiceLayer
    {
        private const string c_fileName = "MapTiles\\{0}_{1}_{2}.jpg";
 
        protected override void GetTileSource(int level, int row, int col, Action<ImageSource> onComplete)
        {
            string fileName = string.Format(c_fileName, level, row, col);
 
            FileStream fileStream = null;
            if (Isolated.FileExist(fileName) && Isolated.ReadFile(fileName, out fileStream))
            {
                BitmapImage image = new BitmapImage()
                {
                    CreateOptions = BitmapCreateOptions.DelayCreation
                };
                image.SetSource(fileStream);
                onComplete(image);
            }
            else
            {
                base.GetTileSource(level, row, col, onComplete);
            }
        }
 
        public override void Initialize()
        {
            base.Initialize();
            base.TileLoaded += new EventHandler<TileLoadEventArgs>(OfflineArcGISTiledMapServiceLayer_TileLoaded);
        }
 
        void OfflineArcGISTiledMapServiceLayer_TileLoaded(object sender, TiledLayer.TileLoadEventArgs e)
        {
            string fileName = string.Format(c_fileName, e.Level, e.Row, e.Column);
            if (e.ImageStream != null && Isolated.FileExist(fileName) == false)
            {
                Isolated.SaveFile(fileName, e.ImageStream);
            }
        }
    }

總的來說

之前一直用BingMap控件引Google的數據源,后來發現不能做緩存~~~就放棄了,其實BingMap的操控流暢比ArcGIS要好,不過緩存是硬傷,沒辦法,好處是ArcGis的效率還不錯,特別是我需要在Map上加載很多東西的時候,BingMap就會變慢,可能是我處理的方式不太對~~~

哦,還有MapABC的大家也可以參考

總的來說:ArcGis的緩存還是很棒的,哈哈


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM