[Maps-l] What's being done and what needs doing?

Aude aude.wiki at gmail.com
Wed Apr 8 14:06:14 UTC 2009


I have my own OpenLayers extension in development and would like to merge
some of the code.  What it does is parse a tag: <map lat="38.90962"
long="-77.04341" zoom="15" mode="osm">

The "mode" parameter allows specifying osm - OpenStreetMap as the map
source, or WorldWind and can allow other sources such as a custom WMS
server.  There is a variable in LocalSettings.php to specify what modes are
enabled on the wiki.  For what we are doing (just OSM to start with), we can
enable just the OSM mode.  The "mode" parameter could be optional, but the
others required.  If the "mode" parameter is not provided, then the default
mode (e.g. OSM) is used.

The JavaScript is included as a separate js file.

Here are code snippets from my Map.php (main extension file), which makes
calls to a Map.class.php file:

$wgHooks['ParserFirstCallInit'][] = 'wfMapParserInit';

function wfMapParserInit() {
    global $wgParser;
    $wgParser->setHook( 'map', 'wfMapRender' );
    return true;
}

function wfMapRender( $input, $args, $parser ) {
   /* $wgMap is as a public object, with the setupMap function available,
while other parts of the code are protected
     */
    global $wgOut, $wgScriptPath, $wgMap;

    /* pass variables to JavaScript.  right now, there can only be one map
per page, but I would like to put the variables into a multidimensional
array, and handle multiple maps that way.  I'm working on this.
*/
    $wgOut->addScript( "<script type='text/javascript'>var mode='" .
$args[mode] . "'; var lat=" . $args[lat] . ";var long=" . $args[long] .
";var zoom =" . $args[zoom] . ";</script>");

   /* it might be better to have the map.js script call and include the
OpenLayers.js script, rather than do it from php.  That way, if a user does
not have JavaScript enabled, then the JavaScript won't load and things will
be faster
*/
    $wgOut->addScript( "<script type='text/javascript' src='" .
$wgScriptPath . "/extensions/Map/OpenLayers/lib/OpenLayers.js'></script>" );

    // add our custom js that implements and adds OpenLayers maps
    $wgOut->addScript( "<script type='text/javascript' src='" .
$wgScriptPath . "/extensions/Map/map.js'></script>" );

    // code making calls to the OpenLayers.class.php file to setup the map
    $text = $wgMap->setupMap($args[mode]);

    // insert map where the <map> tag was in the wikicode
    $wgOut->addHTML($text);

    return htmlspecialchars( $input );

}

I would like to test if a user has JavaScript enabled, which can be done
with an Ajax call or other way.  If they don't, then don't load all the
external JavaScript, so as to keep the code lightweight and fast.  If the
user does have JavaScript enabled, then load the map.js script.  Depending
on the mode selected, the OSM portion of the js can be loaded, or the
WorldWind portion, or other portion.

As for where to have the OpenLayers code, I would like to have our own copy
which we can keep up-to-date as possible.  It would not be good to reference
the OpenLayers.js directly from OpenLayers or OSM, since those will get
changed as others see fit.  It could be that some change will break our
extension.  When we do update our copy of OpenLayers.js, we can test it with
our extension and make sure everything is okay.

Anyway, in the next few days and over this upcoming weekend, I can hack more
at the code where we integrate OpenLayers and MediaWiki.  I can provide them
as patches or if I can get svn access to the extensions part of the
MediaWiki svn, then I can integrate code myself.

-Kate

On Wed, Apr 8, 2009 at 7:34 AM, Ævar Arnfjörð Bjarmason <avarab at gmail.com>wrote:

> Firstly it's great to see so much interest in this project, we now
> have approx. 60 subscribers to this mailing list just a few days after
> it poofed into existence.
>
> What's the current status of the new boxes Wikimedia-DE is donating,
> and more importantly, do we have people interested in setting up the
> required infrastructure there? I.e. the Planet.osm -> DB -> Mapnik
> tile generation process? Someone at the hacking days volunteered to do
> mapnik stuff but I forget whether we had a DB admin yet.
>
> Anyway, what I've been working on is the MediaWiki related stuff
> mentioned in the techblog:
>
>
> http://techblog.wikimedia.org/2009/04/openstreetmap-maps-will-be-added-to-wikimedia-projects/
>
> I started by hacking the SlippyMap so that it supports multiple maps per
> page:
>
>    http://u.nix.is/phase3/index.php?title=Slippy_Test
>
> It's still somewhat hacky, e.g. it duplicates the whole OpenLayers
> template for each map.
>
> Could someone more familiar with OpenLayers please refactor it so that
> it's possible to just call a function to include the map, something
> like:
>
>    <script type="text/javascript">include_slippymap( lat, lon, zoom,
> ....)</script><noscript><img
> src="http://static.map/lat/lon/zoom</noscript>
>
> I'm not asking for the *extension* to be edited (although that would
> be great), just fore a HTML/JS example.
>
> Note that this is probably easier in OpenLayers trunk due to
> OpenLayers.Layer.OSM being included now:
>
>    http://trac.openlayers.org/ticket/1950
>
> (But I don't know if we want to run OpenLayers trunk)
>
> There are also some more OpenLayers-related issues on the wiki page
> for the extension:
>
> http://wiki.openstreetmap.org/index.php/Slippy_Map_MediaWiki_Extension#Known_issues_.2F_ideas
>
> In particular the Attribution issue & snapping to lat/lon 0/0.
>
> And it it enough to have the alternate static map inside <noscript>?
> Does this work on all the odd browsers out there that we want to
> support? If so that'll make everything else much easier.
>
> As for the static map this is how the Export tab on the OSM site does it:
>
>
> http://trac.openstreetmap.org/browser/sites/rails_port_branches/api06/app/controllers/export_controller.rb#L19
>
> I.e. it redirects to the cgi-bin/export script on the tileserver,
> which is a python program which renders directly from the database:
>
>
> http://svn.openstreetmap.org/sites/tile.openstreetmap.org/cgi-bin/export
>
> For example:
>
>
> http://tile.openstreetmap.org/cgi-bin/export?bbox=-18.1343,65.676,-18.0711,65.6948&scale=27500&format=png
>
> Except on Wednesday you'll see an empty map (only coastline) if you
> look at that, since the osm2pgsql import is running on the tileserver.
> I don't know whether that's something that's a problem we could hack
> around in our own setup while updating the Planet mirror, maybe by
> keeping two database copies. Or maybe by just creating static maps
> from the tiles themselves instead, although they'll still have this
> problem if an area that hasn't been pre-rendered is requested, OSM
> itself is serving 404.png for tiles where that's the case since it's a
> Wednesday.
>
> In any case we need lat/lon/zoom to bbox/scale to use that script as-is.
>
> What else needs be done/hacked up and who's interested in doing it?
>
> _______________________________________________
> Maps-l mailing list
> Maps-l at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/maps-l
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikimedia.org/pipermail/maps-l/attachments/20090408/af70678b/attachment.htm 


More information about the Maps-l mailing list