]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/osm.pm
Fix diffurl links (cvsweb expects unescaped '/').
[ikiwiki.git] / IkiWiki / Plugin / osm.pm
index d86dbd66ec9d992aeb33243e95d64357fdd20d42..a7baa5f2b968ebb0464a787be7371a26a2f98423 100644 (file)
@@ -67,10 +67,10 @@ sub getsetup () {
                        safe => 0,
                        rebuild => 1,
                },
-               osm_map_url => {
+               osm_layers => {
                        type => "string",
-                       example => "/tiles/\${z}/\${x}/\${y}.png",
-                       description => "Url to get map tiles from (if none specified, uses the openstreetmap server, see http://wiki.openstreetmap.org/wiki/Creating_your_own_tiles for more info on serving your own tiles)",
+                       example => { 'OSM', 'GoogleSatellite' },
+                       description => "Layers to use in the map. Can be either the 'OSM' string or a type option for Google maps (GoogleNormal, GoogleSatellite, GoogleHybrid or GooglePhysical). It can also be an arbitrary URL in a syntax acceptable for OpenLayers.Layer.OSM.url parameter.",
                        safe => 0,
                        rebuild => 1,
                },
@@ -359,23 +359,29 @@ sub writekml($;$) {
        foreach my $map (keys %waypoints) {
                my $output;
                my $writer = XML::Writer->new( OUTPUT => \$output,
-                       DATA_MODE => 1, ENCODING => 'UTF-8');
+                       DATA_MODE => 1, DATA_INDENT => ' ', ENCODING => 'UTF-8');
                $writer->xmlDecl();
                $writer->startTag("kml", "xmlns" => "http://www.opengis.net/kml/2.2");
                $writer->startTag("Document");
 
                # first pass: get the icons
+               my %tags_map = (); # keep track of tags seen
                foreach my $name (keys %{$waypoints{$map}}) {
                        my %options = %{$waypoints{$map}{$name}};
-                       $writer->startTag("Style", id => $options{tag});
-                       $writer->startTag("IconStyle");
-                       $writer->startTag("Icon");
-                       $writer->startTag("href");
-                       $writer->characters($options{icon});
-                       $writer->endTag();
-                       $writer->endTag();
-                       $writer->endTag();
-                       $writer->endTag();
+                       if (!$tags_map{$options{tag}}) {
+                           debug("found new style " . $options{tag});
+                           $tags_map{$options{tag}} = ();
+                           $writer->startTag("Style", id => $options{tag});
+                           $writer->startTag("IconStyle");
+                           $writer->startTag("Icon");
+                           $writer->startTag("href");
+                           $writer->characters($options{icon});
+                           $writer->endTag();
+                           $writer->endTag();
+                           $writer->endTag();
+                           $writer->endTag();
+                       }
+                       $tags_map{$options{tag}}{$name} = \%options;
                }
        
                foreach my $name (keys %{$waypoints{$map}}) {
@@ -580,6 +586,7 @@ sub map_setup_code($;@) {
        if ($mapurl) {
                $options{'mapurl'} = $mapurl;
        }
+        $options{'layers'} = $config{osm_layers};
 
        return "mapsetup('mapdiv-$name', " . to_json(\%options) . ");";
 }