Phone 7 Bing card control - add a button when click

I use the latest RTM tools for Phone 7 (downloadable today, October 7, 2010).

I am trying to do a simple thing here:

when the user deletes once on the map control, I want to put a pin there. also, I want to keep the regular built-in map management behavior ( double-tap ).

(If you cannot save both behaviors, then perhaps a long press on the card to put a pushpin).

While trying to figure this out, I came across this documentation about the changes made to the control card for Phone7: http://msdn.microsoft.com/en-us/library/ff955762.aspx

Then I saw a new MapInputEventArgs class that has a ViewportPoint member.

While looking at the code examples in the regular monitoring of the SilverLight map, I saw something like this:

private void OnMouseClick(object sender, MapMouseEventArgs e)
    {
        Point clickLocation = e.ViewportPoint;
        Location location = x_Map.ViewportPointToLocation(clickLocation);

        Pushpin pushpin = new Pushpin(); 
        m_PushpinLayer.AddChild(pushpin, new Location(latitude, longitude));
    }

But in the case of Phone7, I cannot find the appropriate event handler, and I could not find who uses MapInputEventArgs in the map control. A google search gives me only 1 result!

So, where is the corresponding event for "Tap once", and how can I get ViewportPoint after this event has been fired?

Thanks in advance.

+5
source share
3 answers

Just figured it out if you still have problems.

MouseLeftButtonUp MouseLeftButtonDown GetPosition, ,

 private void MapMain_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {

        Point p = e.GetPosition(this.MapMain);
        GeoCoordinate geo = new GeoCoordinate();
        geo = MapMain.ViewportPointToLocation(p);
        MapMain.ZoomLevel = 17;
        MapMain.Center = geo;
        //---create a new pushpin---
        Pushpin pin = new Pushpin();

        //---set the location for the pushpin---
        pin.Location = geo;

        //---add the pushpin to the map---
        MapMain.Children.Add(pin);
    }
+6

, , , , , . boolean:

         bool noPin = false;

, , ( MouseLeftButtonDown MouseLeftButtonUp). Up , , , .

    private void mHome_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    {
        noPin = false;
    }

    private void mHome_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
    {
        if (!noPin)
            PlacePushPin();
    }

    private void mHome_MapPan(object sender, MapDragEventArgs e)
    {
        tbTemp.Text += "pan";
    }

    private void mHome_MapZoom(object sender, MapZoomEventArgs e)
    {
        tbTemp.Text += "zoom";
    }

It is not beautiful, but, it was the best I could do.

+1
source

All Articles