Asked by:
Scale-down Pushpins on WPF map

Question
-
We are using the WPF map as a WPF-based user control embedded within several WinForms applications. The default pushpins work fine, we are just looking for a way to scale them down a bit (generally customers complain they are too large). I would like to keep using the Microsoft.Maps.MapControl.WPF.Pushpin object, but just want to make that one rendering adjustment.
I've studied the existing help on the web but haven't found exactly what I need. Often it seems bound to the map zoom level or else it is heavy with WPF customizations (full WPF-based apps). What I'm really seeking is that prior to map.children.add that I can simply have a way in the calling WinForms app to do some soft of myPushpin.scale or similar to scale the pin down to 1/2 size for instance.
Any assistance would be quite beneficial to me, thanks in advance!
Friday, October 12, 2018 6:17 PM
All replies
-
Hi ve,
Have you tried playing with the pin settings in the interactive SDK?
https://www.bing.com/api/maps/sdk/mapcontrol/isdk/adddefaultpushpin
If you want to control the scale of your pushpin, you could try the solution offered here https://social.msdn.microsoft.com/Forums/en-US/909162ea-3ac5-4960-82ed-6ddf02eb6ead/alter-size-of-custom-pushpin-isnt-working?forum=bingmaps
Sincerely,
Friday, October 12, 2018 8:25 PM -
I am not using v8, I'm using the WPF map. They are entirely different therefore, correct?
Greg
Friday, October 12, 2018 8:53 PM -
Hi Greg,
Sorry, I mostly play with the web control but I suspect there has to be a way. Have you tried using inherited characteristics? The documentation at
https://msdn.microsoft.com/en-us/library/microsoft.maps.mapcontrol.wpf.pushpin.aspx
Shows that this class is a child of Window.Controls
So does setting something like height = height / 2 work?
Sincerely,
Sunday, October 14, 2018 4:55 AM -
I've tried most every property that I can think of, including height/width, etc. Adjusting those doesn't scale the pushpins, it just moves them.
I'd imagine there is just something I'm missing here about how to manipulate the pushpin but I was hoping a WPF map expert could unlock that simple secret for me.
Monday, October 15, 2018 3:42 PM -
Hi Greg,
From the Map Control team I have the following answer:
I think they can do what they want. All map annotations derive from UIElement in the WPF control, so you can add any arbitrary XAML you want as pushpins.
The WPF control does have know limitations and they have the following guidance:
With the new XAML islands feature, you can use the UWP map control in a WPF app. That should be the recommended path for WPF development.
So using a XAML Island will get you the benefits of the V8 control within a WPF solution.
Sincerely,
IoTGirl
Tuesday, October 16, 2018 5:43 PM -
There are several good examples of how to customize WPF pushpins, just search for "Bing maps WPF custom pushpin" for example:
https://dennis.bloggingabout.net/2012/10/17/bing-maps-on-wpf-and-custom-pushpin-tutorial-for-pixelsense/
https://stackoverflow.com/questions/27276692/xaml-create-controltemplate-for-map-pushpin
And a small clarification, using XAML islands will allow you to use the UWP map control within a WPF or Win32 app. This is unrelated to using the V8 HTML control in WPF (which is also possible through hosting a web view, but a bit harder to deal with).
- Proposed as answer by IoTGirlMicrosoft employee Wednesday, October 17, 2018 7:26 AM
Tuesday, October 16, 2018 8:12 PM -
Thanks Duncan!Wednesday, October 17, 2018 7:27 AM
-
He stated that he doesn't want to use WPF so I think he's got the control in one of those WPF-host controls in WinForms. That means no XAML.
I'm guessing the easiest way around this would be to make a WPF user control, put special pin handling in that (either swapping out the template as above or just making your own pin graphics), then host that custom control instead of the BingMap itself. It still requires some WPF coding but at least you don't need to rewrite the whole application in WPF.
Monday, October 22, 2018 5:25 PM