Marcus
Marcus

Reputation: 116

Pushpin events C#?

https://learn.microsoft.com/en-us/bingmaps/v8-web-control/map-control-concepts/pushpins/pushpin-events-example

If I'm trying to make an app on C# using Bing Maps API, is it possible to have pushpin events like in the link above? Some sample code I found lets me put a pushpin like thisenter image description here

This is the section of code that created 4 pushpins(only 2 visible in the picture).

var r = new ImageryRequest()
        {
            CenterPoint = new Coordinate(coord1, coord2),
            ZoomLevel = 5,
            ImagerySet = ImageryType.RoadOnDemand,
            Pushpins = new List<ImageryPushpin>(){
                new ImageryPushpin(){
                    Location = new Coordinate(45, -120.01),
                    Label = "hi"
                },
                new ImageryPushpin(){
                    Location = new Coordinate(0, 1),
                    IconStyle = 3
                },
                new ImageryPushpin(){
                    Location = new Coordinate(coord1, coord2),
                    IconStyle = 20
                },
                new ImageryPushpin(){
                    Location = new Coordinate(33, -75),
                    IconStyle = 24
                }
            },
            BingMapsKey = BingMapsKey,
            
        };

Upvotes: 1

Views: 99

Answers (1)

rbrundritt
rbrundritt

Reputation: 18013

It looks like you are using the BingMapsRestToolkit that provides a c# API for accessing the Bing Maps REST services. In particular, you are calling the static imagery service which returns an image, not an interactive map. If you wanted to write some code so that someone could click on a pushpin in the image and you would know it, there would be a decent amount of math involved. It can be done, but you might be better to first consider using an interactive map SDK in your app instead as that would provide a lot more capabilities that would allow the user to interact with the map. Bing Maps has two interactive map SDKs that you can develop with using C#.

There is the Windows UWP map SDK that can be used in Windows apps, and in WPF apps via a XAML island. Here are some useful resources:

There is also an older WPF SDK that has fewer capabilities than the UWP SDK. It is generally recommended to use the UWP map control, but if you want to use this, here are the details: https://learn.microsoft.com/en-us/previous-versions/bing/wpf-control/hh750210(v%3dmsdn.10)

Upvotes: 1

Related Questions