spacer1
spacer2 1_1 1_2
2_1
 Subscribe
 The MP2K Update!
 
 
 
 Magazine
Front Cover
What's New
Articles
News
Sample Data
Gallery
Advertise
About
 Features
MapPoint 2013
Press Releases
MapPoint Forums
Companies
Link to MP2Kmag
Wish List
MapPoint Trial
Authors
 Earlier Content
Past News Items
Past What's New Announcements
 Sponsors
 Order

MapPoint 2013

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
SVG Tutorials
MapPoint

Map Visitors

  ARTICLES  


Finding Sites Within a Specified Distance From an Address

This article demonstrates the use of MapPoint's COM add-in capability to display locations from a database within a specified distance from a reference point.

Assumptions:

Note: This code uses MapPoint North America, but it can be easily modified to use fields more appropriate for European addresses.

In your add-in, create a form. Add a combo box called "cmbPushpin". This will be used to list all pushpins in the "My Pushpins" collection on your map. Create a text box called "txtTolerance" where you will enter the distance around the selected pushpin in which to find addresses. For this example the distance is in miles. Also, add a command button "cmdMap" that will be used to trigger the map creation.

In the Add-in designer procedure fired when the form above will be displayed, add the following code:

You now have a form loaded with a combo box listing any Pushpins that are on the underlying map.

Before going on let me spend a minute on data issues. Unfortunately, MapPoint's ability to handle data is not all that it could be. If you build an ADO recordset, you can't directly import the points into a MapPoint dataset. You can only create pushpins as demonstrated in the code example below. This means that you really only have 2 fields to use for data: Name and Note. The other way to get data in and bring in all desired fields is to use the ImportData method, but with SQL Server that means using a UDL (Universal data link) file and limiting the syntax of how you access SQL Server objects. For example, I don't know how you could use a stored procedure. This is my single biggest gripe with MapPoint. (If I am incorrect about this, someone please set me straight.)

Put the following code behind the "cmdMap" command button. See comments in the code for details of how this works. At a high level, the code determines the latitude and longitude of the selected pushpin, queries the database for points whose latitudes and longitudes are in a rectangle that is slightly larger than the desired radius and uses the MapPoint "Distance" method for each point in the rectangle to determine whether it falls within the desired distance.

To use this:

  1. Put a pushpin on the map,
  2. Select the map form from your add-in options,
  3. Select the desired pushpin and enter the desired distance in the text box,
  4. Click the map button.

You now have all of the points on your database that are within the specified distance from the reference point. Clearly, additional filtering can be done to limit the displayed data and make this even more useful.

Discuss this story in the forum.

Author: Walt Cygan
Email: wcygan(AT)macrogroup.net
URL: http://www.macrogroup.net
Walt is a consultant for The MACRO GROUP, Inc. in Minneapolis, Minnesota. The MACRO GROUP, Inc. is an information systems consulting firm whose customers include public, private and non-profit organizations of all sizes.



Google
 
MP2Kmag Internet


 Recent Discussion
-Are you hyped for adidas NMD R1 Thunder?
-ASA OILMAP v6.4
-Concept SpiceVision v6.8.12
-Aveva.ERM v13.0.1
-ArtWork.NetexG.V1.52
-Aveva everything3D v2.1
-Concept RTLvision v6.8.12
-ArtCAM.v2018
-Auton.v7.24
-Concept GateVision v6.8.12
-ARM DS5 Development Studio v5.27
-AutoSPRINK VR12
-Compucon EOS3 v3.0.1.5
-ARKAOS Mediamaster pro v5.2.3
-AutoSPRINK VR11
-Compass.RamSeries.V11.0.5
-AristoCAT.2016.build.14.04.2017
-AutoPol.v2010
-ColorGate v10
-AQWA
-AWR Design Environment With Analyst v13.0 x64
-CodeV 11.1
-APS v7.6
-AVEVA.Review v12.2.x64
-Cloudworx v4.3
 Resources
Browse GIS books and periodicals
Find a MapPoint Partner or Consultant
Real Estate Thornbrook Subdivision


Want Your Site To Appear Here?

   © 1999-2012 MP2K. Questions and comments to: website@mp2kmag.com
  Microsoft and MapPoint 2002/2004/2006/2009/2010/2011/2013 are either trademarks or registered trademarks of Microsoft.