POST
|
I have a collection of Users which are bound to a GraphicsLayer using a PointDataSource. The graphics appear OK, but the MapTips do not bind to the User properties. My User class looks like this:
public class User
{
public User()
{
//empty
}
public User(double lon, double lat)
{
this.Latitude = lat;
this.Longitude = lon;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public double Longitude { get; set; }
public double Latitude { get; set; }
} My ViewModel also exposes a Users ObservableCollection which is bound to my PointDataSource. <!-- data source -->
<esri:GraphicsLayer.GraphicsSource>
<esri:PointDataSource
ItemsSource="{Binding Source={StaticResource usersViewModel}, Path=Users}"
XCoordinateBinding="{Binding Longitude}"
YCoordinateBinding="{Binding Latitude}" >
</esri:PointDataSource>
</esri:GraphicsLayer.GraphicsSource>
How can I bind my MapTip to display the FirstName and LastName properties from my user? Currently I have this below, however the DataContext on the Border is always null. I don't know how to bind this to the point which contains the User instance for each specific map tip. <!-- tooltip -->
<esri:GraphicsLayer.MapTip>
<Border Padding="4,2" Background="Black" DataContext="{Binding [DataContext]}">
<StackPanel>
<TextBlock Foreground="White" Loaded="TextBlock_Loaded">
<Run Text="User: " />
<Run Text="{Binding FirstName}" />
<Run Text="{Binding LastName}" />
</TextBlock>
</StackPanel>
</Border>
</esri:GraphicsLayer.MapTip>
Graphics display correctly for each User (Lat/Long is good) but the MapTips appear empty. Thanks
... View more
02-27-2013
06:46 AM
|
0
|
1
|
335
|
POST
|
Ok, I figured out my Zooming issue works if I listen for the FullExtent property to change, not the Graphics. I was afraid this code would result in an infinite loop (I thought ZoomTo changes the FullExtent property of the map control) but it apparently doesn't. GeoRssLayer rssLayer = map1.Layers["GeoRSSLayer"] as GeoRssLayer; rssLayer.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(rssLayer_PropertyChanged); void rssLayer_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "FullExtent") { GeoRssLayer rssLayer = map1.Layers["GeoRSSLayer"] as GeoRssLayer; map1.ZoomTo(rssLayer.FullExtent); } } Hopefully this won't result in other problems zooming in every time the full extent property changes. If I just listen for Graphics to change, then the ZoomTo method does not work. Probably because the Graphics layer hasn't updated its layout at that moment yet.
... View more
09-21-2012
12:58 PM
|
0
|
0
|
241
|
POST
|
Thank you, this does answer my question. Unfortunately it doesn't resolve my entire issue, but i'll create a new thread since the issue is unrelated now to the topic.
... View more
09-21-2012
12:45 PM
|
0
|
0
|
241
|
POST
|
Hi, I'm using GeoRSSLayer and I dynamically change the Source URI at runtime. I'm trying to capture when the Graphics.CollectionChanged. But it's not working. Here is my code: On page load: GeoRssLayer rssLayer = map1.Layers["GeoRSSLayer"] as GeoRssLayer; rssLayer.Graphics.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(Graphics_CollectionChanged); In button click event: GeoRssLayer rssLayer = map1.Layers["GeoRSSLayer"] as GeoRssLayer; rssLayer.ClearGraphics(); rssLayer.Source = new Uri(source); // source is a new feed url rssLayer.Update(); Unfortunately, even though the graphics get updated successfully (I can watch during debug they go from 20 to 0, to 20, to 0, etc). the CollectionChanged event NEVER fires. I need to call ZoomTo method after the graphics layer is updated to zoom in wherever graphics are. If you have any other suggestions on how to perform a ZoomTo after the Source URI changes on a GeoRSSLayer that would work. Of course I can't just simply call ZoomTo in my code after I set the Source because it's asynchronous and I don't see any Completed type events on the GeoRSSLayer to know when it's done loading. void Graphics_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { GeoRssLayer rssLayer = map1.Layers["GeoRSSLayer"] as GeoRssLayer; map1.ZoomTo(rssLayer.FullExtent); }
... View more
09-13-2012
12:55 PM
|
0
|
3
|
559
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|