Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
170
How do the xamMap coordinates work?
posted

Hey I've been messing around with the xamMap control for potential use in an upcoming project and I'm curious if I'm missing something about map coordinates. I was checking our the EarthQuakes example that Infragistics provided to sort of learn how the controls worked. As far as I know I have things set up correctly and created a couple "points" and attempted to add them to the map. For some reason they are not showing up. I'm not sure if its because of the coordinates I chose or what but I'm sorta confused.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

<StackPanel>

 

 

 

 

<igMaps:XamMap x:Name="myMap" IsClickable="False" MapProjectionType="Lambert" >

 

 

 

 

<igMaps:XamMap.Layers>

 

 

 

 

 

<igMaps:MapLayer x:Name="mapLayer">

 

 

 

 

<igMaps:MapLayer.Reader>

 

 

 

 

<igMaps:ShapeFileReader Uri="/../ClientBin/Shapefiles/usa_st">

 

 

 

 

</igMaps:ShapeFileReader>

 

 

 

 

</igMaps:MapLayer.Reader>

 

 

 

 

</igMaps:MapLayer>

 

 

 

 

 

<igMaps:MapLayer x:Name="symbolLayer">

 

 

 

 

<igMaps:MapLayer.ValueTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<Image Source="Resources/marker.png" Height="50" Width="50" />

 

 

 

 

</DataTemplate>

 

 

 

 

</igMaps:MapLayer.ValueTemplate>

 

 

 

 

</igMaps:MapLayer>

 

 

 

 

 

</igMaps:XamMap.Layers>

 

 

 

 

</igMaps:XamMap>

</StackPanel>

 

 

private void AddMapElements()

{

 

 

if (_vm.Spots != null)

{

 

 

MapElementCollection elementCollection = new MapElementCollection();

 

 

foreach (SpotViewModel location in _vm.Spots)

{

 

 

Point coordinates = new Point(location.Longitude, location.Latitude);

 

 

Point origin = myMap.MapProjection.ProjectToMap(coordinates);

 

 

SymbolElement mapElement = new SymbolElement

{

ToolTip = location,

SymbolOrigin = origin,

SymbolType =

 

MapSymbolType.Diamond

};

elementCollection.Add(mapElement);

}

myMap.Layers[

 

"symbolLayer"].Elements = elementCollection;

}

}

 

 

 

 

 

 

 

private void GetEarthQuakeData()

{

 

 

 

List<SpotViewModel> spotData = new List<SpotViewModel>

{

 

 

 

new SpotViewModel(new SpotData("1", "Location 1", DateTime.Now, 0, 0, "Somewhere")),

 

 

 

new SpotViewModel(new SpotData("2", "Location 2", DateTime.Now, 100.0, 200.0, "Another Place"))

this is basically all I got going on besides some constructors that call all this and some getters and setters of data.

Any help would be awesome.

Parents
  • 2505
    Offline posted

    Hi MattMacd,

    The WorldRect property of the symbolLayer needs to be set prior to adding the SymbolElements to it. A sample approach is the following:
            private void AddMapElements()
            {
                IList<SpotDataModel> data = GetEarthQuakeData();
               
                if (data != null)
                {
                    MapLayer layer = myMap.Layers["symbolLayer"];

                    layer.WorldRect = myMap.Layers[0].WorldRect;

                    MapElementCollection elementCollection = new MapElementCollection();

                    foreach (SpotDataModel location in data)
                    {
                        Point coordinates = new Point(location.Longitude, location.Latitude);

                        Point origin = myMap.MapProjection.ProjectToMap(coordinates);

                        SymbolElement mapElement = new SymbolElement
                        {
                            ToolTip = location,
                            SymbolOrigin = origin,
                            SymbolType = MapSymbolType.Diamond,                       
                        };

                        elementCollection.Add(mapElement);
                    }
                    layer.Elements = elementCollection;
                }
            }
    The other thing is that the (0,0) point is geographically located somewhere near Africa's west coast, so it cannot be visualized in this case. Also the latitude should be a value between -90 and 90 degrees.
    Sample coordinates of points which could be visualized are (40.713956,-73.959961), (39.095963,-75.498047) which both belong to locations somewhere on the USA's east coast.

    Best regards,
    Milana Zhileva

Reply Children
No Data