Hi
Is it possible to join the data of a Sqlite table with a ShapeFile.
I want to use this data for label on the map.
Thanks
Laurent M
Join a database
Hi Maumet,
I think it is possible, would you please try the blow codes see if it is fit for your case:
ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer();
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.County1("label");
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
layer.DrawingFeatures += layer_DrawingFeatures;
void layer_DrawingFeatures(object sender, DrawingFeaturesEventArgs e)
{
foreach (Feature item in e.FeaturesToDraw)
{
// Get addtional information from sqlite database.
string extentLabel = getInforFromSqlite(item.ColumnValues["name"]);
item.ColumnValues.Add("label",extentLabel);
}
}
Please let us know if any questions.
Thanks,
Troy
Hi
I try this code:
ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer();
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.County1("label");
layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
layer.DrawingFeatures += layer_DrawingFeatures;
void layer_DrawingFeatures(object sender, DrawingFeaturesEventArgs e)
{
foreach (Feature item in e.FeaturesToDraw)
{
string extentLabel = getInforFromSqlite(item.ColumnValues["IdUnique"]);
item.ColumnValues.Add("label", extentLabel);
}
}
private string getInforFromSqlite(string valjoin){
return "test";
}
There is an error:
The given key was not present in the dictionary. (IdUnique ??)
If I try with
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.County1("IdUnique");
The given key is ok but, of course, the labels are my IdUnique.
It is necessary that the column "label" exist in the shpfile ?
Thanks
Laurent M
Hi Maumet,
Oh, sorry to forget the column won’t be added into the DrawingFeatures by default, we need to add additional required column for style:
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.County1(“label”);
layer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.RequiredColumnNames.Add(“IdUnique”);
For question “It is necessary that the column “label” exist in the shpfile ?”: the shape file don’t have to exist a “label” column in it, we can register the CustomColumnFetch event in FeatureSource to append the label column into feature.
void FeatureSource_CustomColumnFetch(object sender, CustomColumnFetchEventArgs e)
{
if (e.ColumnName == “label”)
{
e.ColumnValue = ???
}
}
Please let us know if any questions.
Thanks,
Troy