I have WPF application where I am using ESRI Maps control. Here is my XAML and C# code. Problem is it shows me pin point on the map but it shows me at a wrong place i.e. somewhere Africa. I think its taking the latitiude and logitude as 0,0 i.e. center. Anyone please help me with the issue for the map to pin point to the right location.
<Border CornerRadius="10" BorderThickness="10" Background="LightBlue">
<!--ESRI-->
<esri:Map Name="DashboardMap" Width="550" Height="300" BorderThickness="3" WrapAround="True" IsLogoVisible="False" Loaded="DashboardMap_Loaded" Margin="5,5,0,0">
</esri:Map>
</Border>
Here is my CS code.
private void DashboardMap_Loaded(object sender, RoutedEventArgs e)
{
Layer Arlayer = new ArcGISTiledMapServiceLayer
{
ID = "StreetLayer",
Url = "http://services.arcgisonline.com/arcgis/rest/services/World_Street_Map/MapServer"
};
DashboardMap.Layers.Add(Arlayer);
}
GraphicsLayer layer;
MapPoint point = new MapPoint(37.428433999999996, -122.0723816);
point.SpatialReference = new SpatialReference(102100);
//point.SpatialReference = new SpatialReference(4326);
//point.SpatialReference = DashboardMap.SpatialReference;
layer = new GraphicsLayer();
layer.Visible = true;
ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol symbol = new ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol();
symbol.Color = new System.Windows.Media.SolidColorBrush(Colors.Red);
symbol.Style = ESRI.ArcGIS.Client.Symbols.SimpleMarkerSymbol.SimpleMarkerStyle.Circle;
symbol.Size = 15;
Graphic graphic = new Graphic();
graphic.Symbol = symbol;
graphic.Geometry = point;
graphic.SetZIndex(1);
layer.Graphics.Add(graphic);
DashboardMap.Layers.Add(layer);
}
}
MapPoint takes parameters x and y in that order, so first longitude, then latitude.
You should write:
var point = new MapPoint(-122.072382, 37.428434, new SpatialReference(4326));