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

MapPoint 2006

Programming MapPoint in .NET

MapPoint Book

  Spatial Community
ViaVirtualEarth
SVG Tutorials
MapPoint

Map Visitors

 Direct Media

IT support London
Connect is a London based Personal Computing company. We can provide you with unlimited access to an IT helpdesk and on-site support.

ink refill
Get an ink refill online from us. Black, cyan, magenta and yellow! Full refilling equipment and instructions with diagrams. Check it out!

Flights Lanzarote
Volcanic landscapes to explore and warm white sandy beaches to relax on. For flights to Lanzarote search Holiday Hypermarket.

Greece Holidays
Greece is rich in modern and ancient history making for a fantastic holiday destination. On The Beach holidays specialise in cheap holidays.

bulgarian property
Bulgarian beach and ski property available. High quality, luxury apartments available. See online today!

Cheap Flights to Miami
Search through the wide selection of airlines, travel agents and tour operators offering cheap flights to Miami at dealchecker.co.uk! See now!

Crete
Crete- the largest and most spectacular of the Greek islands is a possibility for your next vacation. Check out Ulookubook.com for great bargains.

  ARTICLES  


Automating MapPoint with Perl

This article shows how to access the MapPoint API from Perl using the Win32::OLE module. Topics include basic Perl syntax, how to call MapPoint methods, and how to set MapPoint API properties.

I've been a fan of using Perl for manipulating text files for some years having previously used AWK. Both are free, but the main advantage of using Perl is the enormous variety of modules available ranging from HTML and XML parsers, image manipulation libraries, communications and networking, mathematics libraries and so on.

One the the modules is a library for calling programs via Windows OLE. Windows applications including Microsoft Office and MapPoint can be accessed programmatically and controlled from Perl. Perl Camel

ActiveState provides Perl for Windows in an MSI package which is freely downloadable. After it is installed, all that is required to begin executing Perl scripts is a text file which the extension .pl containing the code. There is no "project" file or compiling that needs to occur, Perl scripts are interpreted and executed on the fly making for a very easy learning curve.

The script below defines an array with the U.S. State names, instantiates MapPoint, and loops through the array saving a map for each state. Regular readers will recogize this as being very similar to the Automating MapPoint with the .NET SDK article published last year which basically accomplishes the same thing with the free VB .NET compiler found in the .NET SDK.

Both approaches allow you to program MapPoint for free, but in comparison automating MapPoint with Perl is much easier, not least because some de-bugging output is returned, aiding greatly in tracking down syntax errors.

Here is the script, you simply need to put this code in a text file and rename it with a .pl extension and just that simply you are able to automate MapPoint without needing an expensive development tool.

The first few lines tell the Perl interpreter to include the Win32::OLE module required for communicating with MapPoint. The next section defines the array of U.S. states. If you have the European version of MapPoint, replacing this with County or Major City names should work fine.

The next section instantiates MapPoint and opens a new map. In Perl, Methods are called using the -> characters. In the for loop that follows, FindPlaceResults is used to bring up each state in the array, "GoTo" the states and then save an html file. Note the last lines, properties are set using the curly brackets {}.

featured resources
- Sound Business Practices - essentials already written and ready to use.
- Saving a marriage is all about time and effort.

That's it! The files that are produced include an html file and directory for each state and the image file itself is simply called image_map.gif. Perl is great and file and directory manipulation, it would be trivial to get 51 gif files with the name of the state such as North_Dakota.gif. Other Perl modules would give you ability to manipulate or re-size the image and ftp it to a location or otherwise send it somewhere, create a PDF document with the map, and more. The applications are endless, I would encourage any developer to peruse the available Perl modules and scripts on CPAN to add to your arsenal of programming tools.

Discuss this story in the forum.

Author: Eric Frost
Email: website(AT)mp2kmag.com
URL: http://www.mp2kmag.com
Eric is Editor and Publisher of MP2K Magazine and is a part-time student in University of Chicago's evening MBA program. Eric recently finished the MP2Kmag Guide What's New in MapPoint 2004.



Google
 
MP2Kmag Internet


 Recent Discussion
-Virtual Earth Case Study: Regional Government Alliance Builds Connections with Integrated Mapping
-Virtual Earth on CSI: New York
-Helping out after the China quakes
-Coastal Boundaries
-Mapping Earthquakes in China
-An invalid argument was encountered.
-Navman Wireless Oem Solutions Enhances Leading Line Of Gps Receiver Modules
-T-mobile UK
-Virtual Earth and OpenLayers
-Reminder: Microsoft Virtual Earth Partner Webinar and Offer for Free Training
-Virtual Earth Quarterly Technical Briefing
-Customize User Page
-Information about area
-Territory information
-Gps task pane in ActiveX
-Worldwide Telescope Now Available!
-c++ - setting the color of a line
-Initial Costa Rica MapServer map is up & running!
-Satellite Images of Myanmar Cyclone Damage
-Virtual Earth Loyalist: Aerial View
-Leaving messages on the Virtual Earth for Government blog site
-Virtual Earth Webcast: Adding Mapping Capabilities to your Applications with Virtual Earth
-Get new Lat & Lon from speed
-Integrating Virtual Earth Maps and Excel 2007
-Zillow.com
 Resources
Browse GIS books and periodicals
Best Car Contract Hire Lease Save
Find a MapPoint Partner or Consultant
Real Estate Columbia Homes for Sale by Owner
Search for Topaz Jewelry Bargains


Want Your Site To Appear Here?

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

• Replacement Cordless Phone Batteries from DSMiller
Improve your career with a computer degree LocalEDU.com
• Tim Cohn's Marketing Strategy Consultancy
• Buy Toner, Ink Cartridges & Drums at Marquee Office Solutions
• Looking for Dry Erase Boards? See Dry Erase Boards
• 5339 - We Know Bikes: Road Bikes / Triathlon Bikes / Mountain Bikes / BMX Bikes
• Buy Your Car Used Cars, Car Lease and Contract Hire