ThinkGeo.com    |     Documentation    |     Premium Support

How to add a marker with only country name? (Without Lat/Long)

Hi,


I want to create a marker on the center of a country without using Lat and Longs given only the country name, is this possible, is there sample code I can reference?  What about City Name, Country Name?


Thanks!



 Hello Yang,


 
Yes it's possible to do this, first you can get the feature(country area) by country name, then get the center of the area, and put your marker on it.
 
Please refer the code below:

                ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(MapPath("~/SampleData/world/cntry02.shp"));
                Collection<Feature> feature = worldLayer.FeatureSource.GetFeaturesByColumnValue("city name", "Dallas");
                feature[0].GetBoundingBox().GetCenterPoint();

 
Regards,
 
Gary