We are using WPF Bing Maps to visiualize clustered data. We are trying to update data on every OnViewChangeOnFrame event (because there is a significant delay in OnViewChangeEnd). However zooming and updating on every frame leads to "jerking" effect. The idea is to find out the target boundary rectangle OnViewChangeStart and update data only once in the beginning of zoom or pan for the target settings.
However there is a problem Bing Maps - Map class does not support TargetBoundingRectangle property. Is there an algorithm knowing viewportsize, target zoomlevel and target center to calculate TargetBoundingRectangle or maybe another Map property which has it?
Thanks!
Got an answer from MSDN forums.
WPF Bing Maps does not provide target boundary property right now.
Related
I'd like a user to be able to draw a polygon using the Azure Maps Drawing Manager and have the ability to move a point of the polygon to near one of another polygon's points and have the dragged point snap to the same location such that the resulting 2 points would be the same.
I know there is snap capability with a grid but don't see a sample for this behaviour?
The ultimate goal is to prevent polygon overlaps, assuming the intersecting shared line of adjoining shapes is excluded from determination of which polygon a point resides within.
I can allow a user to manually draw and get as close as possible of course, and provide some assertion to confirm no polygons overlap but would additionally like a nice snap-to-point experience if possible.
You can find hundreds of samples for Azure Maps here: https://samples.azuremaps.com/
As you noted, the snapping grid is likely the best place to start in your scenario. Here are some specific samples of this:
https://samples.azuremaps.com/?sample=use-a-snapping-grid
https://samples.azuremaps.com/?sample=snap-grid-options
The following sample is an example of a custom snapping scenario where the routing service is used to snap a drawn line to a route (the route part can be swapped out for custom logic): https://samples.azuremaps.com/?sample=snap-drawn-line-to-roads
I really want to create circular slider. I've been searching, but I can't find any information. So any tutorial, guide or if someone already created like this. Please post their XML code.
Instead of making a circular slider (which as #auburg points out) would be a little unintutive to use (think the old telephone dials), consider making it a dial like a thermostat:
It's functionally very similar, but has a much larger hit-test area and is therefore less easy to mess-up for the user.
Try this guide: https://blogs.msdn.microsoft.com/jerrynixon/2012/12/06/walkthrough-building-a-sweet-dial-in-xaml-for-windows-8/
A circular slider can be implemented just like a normal horizontal or vertical slider. The only difference would be that in the MouseMove event handler of the thumb during the drag operation you cannot just handle the horizontal or vertical position. Instead you have to calculate the angle relative to the center of the slider and map that to the value of the slider.
I'm trying to work with Bing Maps in WPF, but everything is confusing as searching online leads me to false hope. I'll search for something, but get the AJAX version instead of the WPF version. If anyone can point me to proper documentation or help with this issue then I will be forever in their debt.
I have a map in my WPF app that I would like to track when a user is scrolling. I tried tying the map to the DragEnter event, but that didn't do anything. My question is if there is an event that I can use to check if the user is panning or zooming through the map?
Thanks in advance.
The event ViewChangeOnFrame seems to do what you want.
See Handing Map Events
<m:Map ViewChangeOnFrame="MyMap_ViewChangeOnFrame" ...>
From MSDN
Assuming you have a TextBlock element named CurrentPosition defined in
the XAML design code, you can track the current position of a map view
while it is animating between locations. This code tracks the
position, in latitude and longitude, of the northwest and southeast
corners of the bounded map view.
void MyMap_ViewChangeOnFrame(object sender, MapEventArgs e)
{
//Gets the map that raised this event
Map map = (Map) sender;
//Gets the bounded rectangle for the current frame
LocationRect bounds = map.BoundingRectangle;
//Update the current latitude and longitude
CurrentPosition.Text += String.Format("Northwest: {0:F5}, Southeast: {1:F5} (Current)",
bounds.Northwest, bounds.Southeast);
}
I'm working on a WP7 app that uses bing maps to display ~600 pushpins. When i add them to the map using map.Children.Add(pushpin) the UI freezes for ~200 ms. I've seen that in silverlight you can use Microsoft.Maps.EntityCollection to add pins to a map but unfortunately I couldn't find how to use the assembly on WP7. Does anyone know a solution to this?
Maybe you're looking at the problem the wrong way round. WP7 is a compact (though powerful) that excels at showing the user what they want to know quickly (when the apps are written properly).
The user can't possibly see 600 pushpins in one go on a device that small, so why not just show them pushpins that are in the viewable area (or close to it) and add pushpins as the user pans around the map?
Alternatively you could "trickle" feed the pushpins by adding them one (or more) at a time using the DispatcherTimer so that the user sees pushpins being gradually added without drastically affecting performance.
Another possibility (which is what I usually do) is to add a MapItemsControl with the DataTemplate set to a Pushpin and to bind the collection to your collection of pushpin locations. If the binding is to an ObservableCollection you can "trickle" feed it as mentioned above if perf is an issue.
In a viewpoint similar to Derek's, I find it highly unlikely that you seriously want to put 600 pins on the screen at the same time. I'm guessing that they span a large geographic area and the user is unlikely to see more than a handful at a time.
If this is the case, you can trivially apply a cliprect to cull your points, then add the resultant modest list to a layer, and Presto! High performance.
In addition, there is the issue of what to do when the user zooms a long way out, bringing so many pins into view that they merge into one big useless but brightly coloured blob. This is a more complex problem traditionally solved with a quadtree, and I have a suspicion that you just said "a what?" but luckily Google is your friend.
Oh, and to address your stated problem - don't add the pins directly to a map. Add them to a MapLayer and then add that.
I've been working with bing maps in Silverlight recently and have things at a good working order. One quirk that I would like to resolve is that all of my shapes that are drawn on the page get rendered on top of the road layer and even worse, the city names. So if my shapes are opaque, you can't read them. I'm figuring that there must be some z-index type property involved but I'm having a hard time finding any information about it.
Does anyone know how to set the stack order of the layers provided? Is there a particular index of the existing layers (roads, street names, city names and so on)?
Don't think so. The base Bing map layers (map, aerial, aerial with labels) are just prebuilt tiled images. Shapes added will be on top of those images.