Hi folks,

I'm pleased to announce a new release of jMaps.  It's been a while
since it has been updated, but I found out it recently features in a
chapter in O'Reilly's JavaScript: The Missing Manual so I decided it
was probably time to fix it up!

The new release has a few major changes which I'll come onto later,
but none should affect your existing code too much (just method names,
as explained later)

This is a branch version with the new Mapifies namespace.  The new
release is available at:

http://www.bitbucket.org/digitalspaghetti/mapifies/

Eventually, this will be merged back into the trunk version, however
the reason for the new code structure is as follows.

If you can't compile with ant, there is a pre-built version here:

http://jmaps.googlegroups.com/web/jquery.jmap.js

Within the source folder, you will see the new Google API stuff in
files like:

Google.Core.js
Google.Markers.js

The application is now split up into separate files for different
functions, to allow more modular code, and it's a hell of a lot easier
to read.  If you don't need a function in the code (say for example
traffic then just don't include it in the build!)  The new ant script
builds the output file, currently only building google, but eventually
it should support other map type too.

The API is mostly the same for function, the only exception being
functions are now capitalized.  So for example seachDirections becomes
SearchDirections and addMarker becomes AddMarker.

Some options may have changed, check the functions defaults() method,
each main function has one of these and contains the default options
to be merged with what your passing.

The library is missing some of the features in the current release,
like streetview.  However these were not finished in release, and I
need to review them.

One of the things to come out the API too is improved callbacks and
chainibility.  Almost every function has a callback which allows you
to access the object you have created.  This does put the onus on you
as the develop to handle events and errors.  Here are a couple of
examples:

* Create a map and marker manager and add a marker and control
visibility with a toggle control.

jQuery('#map').jmap('init',
  {
    mapCenter:[55.958858,-3.162302]
  }).jmap('CreateMarkerManager')
  .jmap('AddMarker',
    {
      'pointLatLng':[55.958858,-3.162302]
    }, function(marker) {
      jQuery('.togglemarker').toggle(function(){
        marker.hide();
      }, function(){
        marker.show();
  });

});

* Add a feed to the map and control it's visiblity

jQuery('#map').jmap('AddFeed',
  {
    'feedUrl':'http://mapgadgets.googlepages.com/cta.kml'
  }, function(feed){
    jQuery('.togglefeed').toggle(function(){
      feed.hide();
    }, function(){
      feed.show();
  });

});

Here is an example of better error handling via callbacks, in this
example between addresses:
jQuery('#map').jmap('SearchDirections',
  {
    'fromAddress':'Edinburgh',
    'toAddress':'Nowhere',
    'panel':'#directions
  }, function(directions) {
    if (!directions.getStatus().code == 200) {
      jQuery('#directions').html('<strong>Directions cannot be found</
strong>');
      return false;
    }
    return true;

});

Anyway, feel free to poke and prod at the code and feel free to
feedback any issues.  There is a public tracker on the repo above that
you can raise tickets to as well.

Thanks,
Tane

--
Tane Piper
http://digitalspaghetti.me.uk
twitter: http://twitter.com/tanepiper

Reply via email to