How to: Load a Vector Cartesian Map from a Shapefile
To load a vector Cartesian map, do the following.
- Crete a ShapefileDataAdapter object.
- Set its CoordinateSystemDataAdapterBase.SourceCoordinateSystem property to a CartesianSourceCoordinateSystem object.
- Specify its FileDataAdapterBase.FileUri property.
- Assign this object to the VectorItemsLayer.Data property.
// Create a vector layer and add it to the map.
VectorItemsLayer hotelLayer = new VectorItemsLayer() {
Data = CreateData(),
Colorizer = CreateColorizer()
};
map.Layers.Add(hotelLayer);
// Creates a shapefile data adapter.
private IMapDataAdapter CreateData() {
Uri baseUri = new Uri(System.Reflection.Assembly.GetEntryAssembly().Location);
ShapefileDataAdapter adapter = new ShapefileDataAdapter() {
SourceCoordinateSystem = new CartesianSourceCoordinateSystem(),
FileUri = new Uri(baseUri, filepath)
};
return adapter;
}