BaifoMAP Code Diving

I forgot to say that I made an screencast with byzanz to show the BiafoMAP behaviour, and also I forgot explain how did I developed the Gecko based widget.

First, I needed to develop the web api, which is here:

<html xmlns="">
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <title>Google Maps JavaScript API Example</title>
  //  function load() {
    if (GBrowserIsCompatible()) {
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GSmallMapControl());
      map.setCenter(new GLatLng(27.972572,-15.586853), 9);
      GEvent.addListener(map, "move", function(){
        var center = map.getCenter();
        window.status ="/"+center.lng()+"/"+map.getZoom();
  </head> <body style="border: 0px; spacing: 0px; margin: 0px;"   onload="load()" onunload="GUnload()">   <div id="map"   style="width: 300px; height: 300px;          spacing: 0px; padding: 0px;          margin: 0px;"/> </body> </html>

This is the basic Google Maps API example plus a key addition:

      GEvent.addListener(map, "move", function(){
        var center = map.getCenter();
        window.status ="/"+center.lng()+"/"+map.getZoom();

This writes the latitude, the longitud, and the zoom, between slashes, everytime the center is moved. Why the hell do I did that? Because GtkMozEmbed emit this signal every time JavaScript change the status:

"js-status"     def callback(mozembed, data, ...)

So we can connect that signal into a callback, which code could look like this:

def status_cb(moz):
        browser_coords = moz.get_js_status()
        lat_value, lon_value, zoom_value = browser_coords.split('/')
        template = """<b>Latitude:</b>          %s
                      <b>Longitude:</b>       %s
                      <b>Zoom:</b>            %s"""
        coords_label.set_markup(template % (lat_value, lon_value, zoom_alue))
moz = gtkmozembed.MozEmbed()
moz.connect("js-status", status_cb)

I think I’ll write a new subclass of MozEmbed which has latitud, longitud and zoom
propierties, and emit it’s own signal everytime the map is moved. For further details on the code, please download the code from the previous post.


I’ve been thinking about integrate georeferencing with classical desktop apps, and I wondered if integration between Google Maps and Gnome is possible, so I started to play around with GtkMozEmbed (Mozilla‘s Gecko Gtk widget), javascript, python and ruby. And this is what I’ve done, a GoogleMapWidget:

This is the package with the python implementation, it requires pygtk, mozilla or firefox and pygtkmozembed (included in python-gnome-extras package):