• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

14. Custom Programming with MapServer’s ... > 14.6. Parallel MapScript Translation...

Parallel MapScript Translations

A simple example is shown in this section using multiple scripting programming languages. Examples 14-5 through 14-9 provide a reference point for programmers who want to see how MapScript can be used in various languages. All these examples do the exact same thing—open a map file, draw the map, and save it to an image file. They are meant to be run in the same folder as the global.map map file, and they all produce an image file called worldmap.png.

Example 14-5. Python MapScript basic example
# map1.py
# Python MapScript Example 1

import mapscript

# Set the map file to use
mapfile = "global.map"

# Create a mapObj, initialized with the mapfile above
mapobject = mapscript.mapObj(mapfile)

# Create an imgObj that has an image of the map
mapimage = mapobject.draw()

# Save the mapimage to a file
mapimage.save("worldmap.png")

PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint