SQLite 到 Arcgis 地图

SQLite to Arc GIS Map

我试图从 SQLite 数据库中获取数据并将其显示在 ArcGIS 地图上,但是当我将图形放在 GraphicsLayer 上并将其添加到地图时,没有显示任何内容。这个方法有什么问题?

C#:

    private void DisplayDatabase(int geometryColumnID = 0)
    {
        //Get the table name and WKT
        var tableName = (string)_DatabaseConnection.CreateCommand("SELECT f_table_name FROM geometry_columns").ExecuteDeferredQuery()[geometryColumnID]["f_table_name"];
        var geometryData = _DatabaseConnection.CreateCommand($"SELECT * FROM {tableName}").ExecuteDeferredQuery();

        //Create a fresh map with a layer that has an ID of tableName
        GISMap.Map = new Map();
        var layer = new GraphicsLayer { ID = tableName };
        GISMap.Map.Layers.Add(layer);
        layer.Renderer = new SimpleRenderer();

        foreach (var shape in geometryData)
        {
            //convert the data to a graphic
            var wktGeometry = shape["WKT_GEOMETRY"] as string;
            var graphic = new Graphic(Geometry.FromJson(ConvertWkt2Json.WKT2JSON(wktGeometry)), new SimpleMarkerSymbol() { Style = SimpleMarkerStyle.Circle, Color = Colors.Red, Size = 17 });

            //add feature to the map
            layer.Graphics.Add(graphic);
        }

        //Initialize the layer
        GISMap.Map.Layers[tableName].InitializeAsync();

        Debug.WriteLine("Map done!");
    }

    private void callDisplay(object sender, RoutedEventArgs e)
    {
        DisplayDatabase();
    }

XAML:

<Page
x:Class="ShapeSQLiteGISDemo.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ShapeSQLiteGISDemo"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Esri.ArcGISRuntime.Controls"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <controls:MapView Name="GISMap" WrapAround="True">
        <controls:Map />
    </controls:MapView>

    <Border Background="#CC000000" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="30" Padding="20" Width="300">
        <StackPanel>
            <Button Content="Import Shapefile Folder to Database..." Margin="0,12,0,0" Padding="5" HorizontalAlignment="Stretch" Click="ImportShapes" />
            <Button Content="Load Database!" Margin="0,12,0,0" Padding="5" HorizontalAlignment="Stretch" Click="callDisplay" />
        </StackPanel>
    </Border>

</Grid>

我在 XAML 中添加了一个 ArcGISTiledMapServiceLayer 并且我的观点出现了,如果您遇到这个问题,请尝试创建一个如下所示的 ArcGISTiledMapServiceLayer(uri 只是一个普通的世界地图)。

    <esri:MapView Name="GISMap" WrapAround="True">
        <esri:Map x:Name="SQLiteMap">
            <esriLayers:ArcGISTiledMapServiceLayer ServiceUri="http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer"/>
        </esri:Map>
    </esri:MapView>