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 8 of 8

ZoomTo or Goto for shapes

This is a discussion on ZoomTo or Goto for shapes within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hi All, Anyone know of a way to ZoomTo a bunch of shapes. I know how to ZoomTo a dataset ...

  1. #1
    jlewis is offline Member Yellow Belt
    Join Date
    Apr 2006
    Posts
    33

    ZoomTo or Goto for shapes

    Hi All,

    Anyone know of a way to ZoomTo a bunch of shapes.

    I know how to ZoomTo a dataset (pushpins) or GoTo a location but there doesn't seem to be an equivalent method for shapes.

    I'm importing a load of shapes onto a map and all I want to do is display all the shapes centered on the map view. I thought about using the Union and GoTo method but getting what could be thousands of shape vertices into an array is really slow!

    Any ideas?
    John Lewis

  2. #2
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: ZoomTo or Goto for shapes

    From where are you importing the shapes?

    I wonder if in your code you could determine the min and max latitudes and longitudes, then you could drop four invisible pushpins onto the map and zoom to that?

    Eric

  3. #3
    jlewis is offline Member Yellow Belt
    Join Date
    Apr 2006
    Posts
    33

    Re: ZoomTo or Goto for shapes

    Hi Eric - thanks for your reply.

    What I'm actually doing is reading a .ptm (which contains some shapes) and doing a 'copy/paste' onto a visible map (user chooses which shapes they want to see) and it's the resulting map/shapes that I want to 'zoomto'.
    John Lewis

  4. #4
    VC_Man is offline Member Green Belt
    Join Date
    Nov 2006
    Posts
    93

    Re: ZoomTo or Goto for shapes

    Than still you need to retrieve all the shapes from the "active map" and check them one by one to get the upper-left corner to lower right corner location. Just like Eric said, make to "unvisible" pushpins of it, put those pushpin to a seperate DataSet and than perform ZoomTo for that particular Dataset. I guess that's the only way you can do that. I don't know how to do it elseway.

  5. #5
    Eric Frost's Avatar
    Eric Frost is offline Administrator Black Belt
    Join Date
    Jul 1992
    Posts
    5,094
    Blog Entries
    4

    Re: ZoomTo or Goto for shapes

    There's an article Walt Cygan wrote that exports the map's shapes to mif/mid text files --
    Spatial Data Importer Contest Submission - MP2K Magazine

    You don't have to do all that, but check out the Vertices property on the Shape object --
    Vertices property

    Returns or sets the array of Location objects that comprise the beginning and ending points for line shapes and the points where angles meet for freeform shapes. The shape must have a Type property of geoLine or geoFreeform. Read/write Variant.


    You would basically have to Loop over the Shapes collection...

    The Shapes collection contains all the shapes on the map. Shapes are returned in z-order from front to back. This collection remains valid after the map is closed and then reopened. This collection supports the Visual Basic For Each...Next statement.
    To learn more about drawing shapes on maps, see the About using shapes in MapPoint and Getting started with shapes reference topics.


    ... and then look at the vertices of each Shape. The Vertices are Location objects and you can use the Latitude / Longitude properties in MapPoint 2006 to check the lat/lon's.

    Note that if you are using MapPoint 2004 then you will have to use a hack to get the lat/lon's --

    A More Compact Method for Obtaining Lat/Long - MapPoint Articles - MP2K Magazine

    hope this helps!

    Eric

  6. #6
    jlewis is offline Member Yellow Belt
    Join Date
    Apr 2006
    Posts
    33

    Re: ZoomTo or Goto for shapes

    Thanks again for your replies Eric & VC_Man!

    Yep - tried all that - but when there could be 10 or 15 shapes - each with between 2 and 3 thousand vertices that's really slow!

    Maybe I'll just leave it to the user to manually zoom to the right place!

    Cheers
    John Lewis

  7. #7
    Paul Larson is offline Senior Member Green Belt
    Join Date
    Sep 2005
    Location
    Battle Creek, Michigan
    Posts
    136

    Re: ZoomTo or Goto for shapes

    If you are getting the shapes from ESRI SHP files, there is a property inherent in the file(s) known as the "bounding box" for each shape. It's easy to re-open the SHP file and extract just this information, which is exactly what you need to properly zoom/pan the ActiveMap window.

    If you use the Spatial Data Importer, the VB source code actually demonstrates reading the bounding box info, although it doesn't make use of it. It's in the module ESRIShapeParser, method GenerateRegions(), after the line
    "If eShapeType = m_eShapeType Then"

    If you're using MapInfo files, you easily can derive a bounding box while parsing the points of a region.

    HTH
    Paul

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

    Re: ZoomTo or Goto for shapes

    Quote Originally Posted by jlewis View Post
    Hi Eric - thanks for your reply.

    What I'm actually doing is reading a .ptm (which contains some shapes) and doing a 'copy/paste' onto a visible map (user chooses which shapes they want to see) and it's the resulting map/shapes that I want to 'zoomto'.
    So your application know whitch shapes are copied ? Then you can have the Location object from each shape and zoom to it with the method Eric has told ?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. What is it: ZoomIn, ZoomOut, ZoomTo or Altitude??
    By VC_Man in forum MapPoint Desktop Discussion
    Replies: 5
    Last Post: 12-22-2006, 07:43 AM
  2. dataSet.zoomTo()
    By chpw in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 05-17-2006, 08:05 AM
  3. Location.Goto functionality, for freeform shapes?
    By Geomancer in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-16-2003, 08:42 AM
  4. ZoomTo Cropping
    By JRussell in forum MapPoint Desktop Discussion
    Replies: 2
    Last Post: 10-27-2003, 11:47 AM
  5. memory leak with objloc.goto?
    By mzupan in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 08-02-2003, 01:14 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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96