Ignore:
Timestamp:
2011-01-16T19:47:42+01:00 (14 years ago)
Author:
guggis
Message:

Updated sample scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/scripting/scripts/HelloWorld.js

    r25072 r25083  
    11/*
    2 * HelloWorld.js  -  sample JOSM script in JavaScript
     2* HelloWorld.js  -  displays the number of actually open layers
    33*/
    44importClass(Packages.javax.swing.JOptionPane)
    55importClass(Packages.org.openstreetmap.josm.Main)
    66
    7 JOptionPane.showMessageDialog(Main.parent, "[JavaScript] Hello World!")
     7function getMapView() {
     8        if (Main.main == null) return null
     9        if (Main.main.map == null) return null
     10        return Main.main.map.mapView
     11}
     12
     13var numlayers = 0
     14var mv = getMapView()
     15if (mv != null){
     16        numlayers = mv.getNumLayers()
     17}
     18JOptionPane.showMessageDialog(Main.parent, "[JavaScript] Hello World! You have " + numlayers + " layer(s).")
     19
Note: See TracChangeset for help on using the changeset viewer.