Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Results 1 to 2 of 2

A simple map with a pushpin on click

This is a discussion on A simple map with a pushpin on click within the MapPoint Desktop Discussion forums, part of the Map Forums category; I just want a simple map on a web page that, when the user clicks on it, the map displays ...

  1. #1
    cojmezek is offline Junior Member White Belt
    Join Date
    Oct 2005
    Posts
    1

    A simple map with a pushpin on click

    I just want a simple map on a web page that, when the user clicks on it, the map displays again with a pushpin in the click location. But, I have a problem that I just can't seem to get around.

    I build a map and place it in a webcontrols image button. On the click event I calculate the latlong and set a pushpin. This all works fine until the map is zoomed or panned and then a subseqeunt map click places the pushpin in the wrong location.

    Any help would be much appreciated!

    Here is the click event code...

    PixelCoord myPixelCoords = new PixelCoord();
    myPixelCoords.X = e.X;
    myPixelCoords.Y = e.Y;
    RenderMap(0, 0, 0, myPixelCoords);

    Here is the RenderMap code... (right out of the sample but with a pushpin)

    void RenderMap(double myPanHorizontalAdjustment, double
    myPanVerticalAdjustment, double myZoomValue, PixelCoord PushPinCoord)
    {
    MapWithNavigationButtonsCS.Global global =
    (MapWithNavigationButtonsCS.Global)Context.Applica tionInstance;

    //Get the latest map specification object
    MapSpecification mapSpec = (MapSpecification)Cache["myMapSpec"];

    //Pan or zoom the map as appropriate
    mapSpec.Options.PanHorizontal = mapSpec.Options.PanHorizontal +
    myPanHorizontalAdjustment;
    mapSpec.Options.PanVertical = mapSpec.Options.PanVertical +
    myPanVerticalAdjustment;

    if (!(mapSpec.Options.Zoom + myZoomValue <= 0))
    {
    mapSpec.Options.Zoom = mapSpec.Options.Zoom + myZoomValue;
    }
    if (PushPinCoord != null)
    {
    PixelCoord [] coordinates = {PushPinCoord};

    LatLong[] centerCoords =
    global.RenderService.ConvertToLatLong(coordinates ,mapSpec.Views[0],
    500, 500);
    Pushpin[] myPushPins = new Pushpin[1];
    myPushPins[0] = new Pushpin();
    myPushPins[0].PinID = "pin0";
    myPushPins[0].IconName = "0";
    myPushPins[0].IconDataSource = "MapPoint.Icons";
    myPushPins[0].LatLong = new LatLong();
    myPushPins[0].LatLong = centerCoords[0];
    mapSpec.Pushpins = myPushPins;

    }
    //Declare the map image array and get the map
    MapImage[] myMapImages;

    try
    {
    myMapImages = global.RenderService.GetMap(mapSpec);
    //Assign the Map Url
    this.Map.ImageUrl = myMapImages[0].Url;

    //Also restore the changed map specification
    Cache["myMapSpec"] = mapSpec;
    }
    catch(SoapException myException)
    {
    }

    }

    Thanks in advance for the help!

    Jay

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    this is how you place the pushpin. It is places exacly where it is clicked:

    Code:
                Location loc = mp.ActiveMap.XYToLocation&#40;e.x, e.y&#41;;
                mp.ActiveMap.AddPushpin&#40;loc, ""&#41;;
    e is the event arguments of the before click event handler.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Double Click on a Pushpin
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 02-28-2004, 07:26 PM
  2. I need help with MP2K Directions, I have a simple app in VB6
    By NickSP in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 02-28-2003, 04:41 PM
  3. a simple question
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-29-2002, 11:53 AM
  4. I am currently trying to develop a simple co-ordin....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-07-2001, 10:38 AM
  5. I am looking at purchasing a simple GIS system to ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 07-18-2001, 06:57 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27