Difference between revisions of "Widget:OSM-Sudoroom-dev"

From Sudo Room
Jump to navigation Jump to search
(copy from Widget:OSM-Sudoroom)
 
(pass width & height units)
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>__NOTOC__
<noinclude>__NOTOC__
This is a homebrew attempt at making an OSM widget in mediawiki ... WITH a marker! (the extension doesn't do markers)
This is a homebrew attempt at making an OSM widget in mediawiki, fancier than the official extension will allow.
</noinclude><includeonly>
</noinclude><includeonly>
<iframe width="<!--{$w|escape:'html'|default:425}-->" height="<!--{$h|escape:'html'|default:350}-->" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=<!--{$swlon|escape:'html'|default:-122.269}-->%2C<!--{$swlat|escape:'html'|default:37.81}-->%2C<!--{$nelon|escape:'html'|default:-122.2666}-->%2C<!--{$nelat|escape:'html'|default:37.812}-->&amp;layer=mapnik&amp;marker=<!--{$mklat|escape:'html'|default:37.810963}-->%2C<!--{$mklon|escape:'html'|default:-122.267652}-->" style="border: 1px solid black"></iframe>
  <div style="width:<!--{$w|escape:'html'|default:425}-->;height:<!--{$h|escape:'html'|default:350}-->;border:1px solid black;margin:0px;" id="mapdiv"></div>
  <script src="https://sudoroom.org/openlayers/OpenLayers.js"></script>
  <script>
    map = new OpenLayers.Map("mapdiv");
    map.addLayer(new OpenLayers.Layer.OSM());
 
 
    var lonLat = new OpenLayers.LonLat( <!--{$mklon|escape:'html'|default:-122.267652}--> ,<!--{$mklat|escape:'html'|default:37.810963}--> )
          .transform(
            new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
            map.getProjectionObject() // to Spherical Mercator Projection
          );
    var zoom=14;
    var markers = new OpenLayers.Layer.Markers( "Markers" );
    map.addLayer(markers);
    markers.addMarker(new OpenLayers.Marker(lonLat));
    map.setCenter (lonLat, zoom);
 
    map.addPopup(new OpenLayers.Popup.FramedCloud("Popup",lonLat, null,
      '<!--{$text1|escape:'html'|default:markertext}-->&nbsp;&nbsp;&nbsp;<br /><br />' +
      '<!--{$text2|escape:'html'|default:markertext}-->' +
      '<br /><hr style="color:#f0f0e7;background-color:#f0f0e7;" />' +
      '<!--{$address|escape:'html'|default:markertext}--> ' +
      '(<a href="<!--{$link|escape:'html'|default:markertext}-->">Directions</a>)', null,true
    ));
  </script>
</includeonly>
</includeonly>

Latest revision as of 21:23, 3 March 2014

This is a homebrew attempt at making an OSM widget in mediawiki, fancier than the official extension will allow.