Thursday, 31 March 2011

The definitive MapGuide/Google Maps integration FAQ

We seem to get this same question over and over again on the mapguide-users mailing list. So I hope this post will definitively answer this question once and for all so that we can have more productive and meaningful discussions. So let's cut to the chase.

Q: Can Google Maps be shown in the AJAX viewer?
A: The answer is: NO

Why? The main reasons are:
  1. The Google Maps API has very tight restrictions on how it is used. I wouldn't be surprised if you'd violate some clause in the Google Maps terms of service if you did significant hacking to the AJAX viewer to have it display Google Maps data.
  2. The AJAX viewer does not use the OpenLayers javascript library. OpenLayers is probably the only legit way to use display Google Maps data.

So simply put, give up on this idea and move on... to Fusion.

Q: Can we show Google Maps in fusion?
A: The answer is: YES

Q: Are there any catches?
A: The answer is also: YES. Your map definition needs to be in the popular spherical mercator coordinate system (CS-Map code: WGS84.PseudoMercator, EPSG code: 3857). If you modified the Map Definition's coordinate system, you have to re-project your initial view extents as well. Note that MapGuide Studio will automatically re-project these extents for you. For Maestro, you will have to figure out these coordinates yourself.

Q: What versions of MapGuide supports this Google Map integration?
A: MapGuide Open Source >= 2.1 or MapGuide Enteprise >= 2010. For MGOS 2.1 and MGE2011, this support needs to be manually hacked in. In newer versions, the support is built-in to the fusion framework and has matching editor support in Studio/Maestro.

Q: Can I enable Google Maps fusion support with MapGuide Studio/Maestro?
A: YES. MapGuide Studio/Maestro have specialized UIs to make this dead simple (See my blog post I made for my old company for how to do this in Studio). In Maestro, the UI is pretty similar.

Q: Why can't I see my Google Maps layers when I [Print / Save Map / Quick Plot ] in fusion?
A: Because this is by design and is also the same reason you won't see Yahoo or Bing layers too. All the aforementioned widgets uses MapGuide's rendering APIs which know nothing about Google Maps. To get these widgets to show Google Maps would probably be another ToS violation.

Q: How can I get Google style popups when I select an object?
A: Use an OpenLayers.Popup and display it on a function listening to Fusion's MAP_SELECTION_ON event. I'm not going to say anymore. Google searching should fill in the rest of the details.

So what if you can't or don't want to use Fusion? Well your only remaining avenue is a purely custom solution via the OpenLayers library (which supports both Google Maps and MapGuide). I won't say much more on this either because there are bajillions of differnent OpenLayers examples/blogs/discussions out there for you to get ideas on figuring out the rest.

Oh, and do read that ToS throughly too!

Friday, 25 March 2011

Maestro 3.0: A comprehensive walkthrough (part 2)

Here's part 2 of the comprehensive walkthrough for Maestro 3.0. This part will showcase the meat of the Maestro application: The resource editors

New Resource Dialog

Creating a new resource in previous versions of Maestro required navigating some menus. For this release, I've taken a different approach:

The design is heavily inspired by Microsoft Visual Studio (It's what I used almost every day!). As you can see, new resource templates are grouped by category. (Note: This dialog will get some tweaks for the next beta)

The dialog is version aware. For example, say you are connecting to a MapGuide Open Source 1.2 server, you will not see the Application Definition resource template as that did not exist in that version. Simply put, you can only create resources that can be supported by the version of MapGuide you are connecting to.

Load Procedure Editor

Load Procedure Support debuted in the previous version, with support for bulk loading SDF and SHP files into MapGuide. For this version, I've added extra support for loading SQLite files (MGOS 2.2/MGE 2011 and newer only) and DWF files. However the same limitations apply from the previous version:
  • No SDF2 to SDF3 conversion support
  • No convert to SDF support
  • No generalization support
  • No DWG support (Not gonna happen)
  • No raster support (Very unlikely to happen)
Despite these limitations, the bulk loading options have been expanded should you need to do a "quick and dirty" loading of data into MapGuide.

As for the user interface, it's still pretty much the same as before

You may be wondering that that pale yellow bar is.

When you open a resource in MapGuide Studio, it will silently upgrade that resource to the latest schema version. This is okay sometimes as your resource can immediately take advantage of any new features exposed in the latest schema version. However if you were to package this data up and load it into an older version of MapGuide, chances are it will fail because it won't recognise your silently upgraded resources.

Maestro on the other hand, will always open the resource as-is. It will never silently upgrade your resources. So suppose we actually do want to upgrade an edited resource, how can we find out if it's upgradeable? Enter the yellow notification bar.

The bar will show if you open a resource and Maestro has determined that a newer version of this resource is supported. You may notice the Upgrade button is disabled. This is because it is currently not implemented yet, but it should give you a clear idea of how I intend for this notification bar to work.

One final thing to note about this bar is that all resource editors support this feature.

Feature Source Editor

The Feature Source editor has had a major makeover from the previous version:

This screenshot is of the SDF feature source editor. Most commonly-used FDO providers have a specialized feature source editor for them, but just like I've done with FDO Toolbox there is a generic editor fallback for lesser known or used providers.

The editor is for the most part similar to its MapGuide Studio counterpart, but if you look down below:

You can launch the Feature Source Preview tool to take a more fine-grained look at the data in that Feature Source. This space will be reserved for other feature source centric tools and functionality in the future.

Layer Definition Editor

The Layer Defintion hasn't changed much. The outer shell has changed but the meat of the editor (all those controls and dialogs to edit the various aspects of the Layer Definition) remains the same. One thing to note is that this does cleanly support all versions of the Layer Definition schema unlike the previous version of Maestro.

Map Definition Editor

Here's another editor that's been given another makeover in the visual department

Functionality-wise, there's nothing much to write home about. It does the same thing as the previous version did, only in more productive ways. For example, you can now drag/drop multiple layers into the editor and you can drag/drop reorder and reorganise layers as well. It beats using those up/down arrows to reorder layers!

Web Layout Editor

The Web Layout Editor has also had a makeover

But one particularly useful feature in this version (which didn't exist in previous versions of Maestro or MapGuide Studio) is down below

For those who can't see it. The Web Layout editor allows you to export your custom commands to a XML file, which can then be easily transferred to another layout by importing this XML file. Now you have an easy mechanism to move your custom commands between Web Layouts!

Print Layout Editor

New in this version is a specialized editor for Print Layouts

I don't really know if this resource is used that much, but given the schema is actually quite simple to create an editor for, I'm surprised that it took this long for such an editor to finally spring up, but here it is at long last!

Fusion Editor

Frankly, I didn't use the Fusion editor in the previous version of Maestro that much because I didn't really use Fusion itself that much. But I've been exposed to Fusion more and more in my line of work, and subsequently finding out the Fusion editor in the previous version wasn't up to snuff, the Fusion Editor in Maestro also received an overhaul

Unlike the editor in MapGuide Studio with its bajillion different tabs, the Fusion Editor in Maestro is simplified into 4 main areas:
  • Template selection
  • Map Group management
  • Container management of widget references
  • Widget management and configuration
The main editor covers the first 3, a Widget Management dialog (accessible via the cog icon in the Widgets toolbar) covers the 4th.

A fair chunk of widgets have specialized editors. But for those that don't, there's always the XML editor fallback

One thing to note as well. If you delete a widget here, it will also remove all widget references from all containers. Because one thing Maestro will always strive do is to preserve the integrity of your resources.

Other Resources

What about Symbol Libraries? Unfortunately, symbol libraries use a DWF file as a backing store and there is no portable .net library out there to manipulate DWF files. So a specialized editor will never happen.

What about Symbol Definitions? Well this is what we all should be using instead of Symbol Libraries, but having not used Symbol Definitions much myself and not being intimately familiar with the Symbol Definition schema has meant that I haven't really been able to quite figure out what is the best user interface for this type of resource. I'll get something happening on this eventually so watch this space.

What about Watermarks? Well this new resource type just came out! Those on Autodesk subscription will soon be receiving their copy of the next MapGuide Enterprise (ahem! I mean: Autodesk Infrastructure Map Server 2012) and will have an updated MapGuide Studio (ahem! I mean: Autodesk Infrastructure Studio) that can create and edit this new type of resource. For us open source folks, the next release that will have Watermark support is quite some time away. That means I'll have plenty of time to get the proper support in.


One of the standout features of Maestro over MapGuide Studio is the ability to validate resources. Validation is one of the easiest ways to detect common problems with your MapGuide repository (eg. Broken resource references, Layers referencing non-existent feature classes)

In this release, I've added many more validation rules. In fact each validation rule now comes with an error code attached, allowing users of the Maestro API to programatically act against validation failures.

Stay tuned for part 3. Where I dive deep into the internals of the Maestro API.

Tuesday, 22 March 2011

Announcing: MapGuide Maestro 3.0 beta 2

I have released the 2nd beta of Maestro 3.0

Remember, this is a beta. Use this release for testing and feedback.

This release includes a specialized WMS feature source editor and a boatload of fixes for assorted defects found in the previous beta and earlier builds.

Tuesday, 15 March 2011

Maestro 3.0: A comprehensive walkthrough (part 1)

As I promised, this is the first part of many posts on showing the many new features of Maestro 3.0.

The Main Application Window

So after you login in, here's what you get:

Look familiar? Yes, the overall UI design is modelled on FDO Toolbox. In fact, Maestro uses a more-refined version of the same extensible foundation and design concepts used by FDO Toolbox. If something works for you, why change it? :)

Originally, I also wanted to use the same DockPanel library as I did in FDO Toolbox, but having found out that the library is riddled with P/Invokes into the Win32 API, it was instantly unsuitable for my needs because getting this thing to work in Mono is a fundamental requirement.

So after failing to find a portable alternative, and the vanilla winforms TabControl being woefully inadequate (no close buttons on tabs???? c'mon!) I had no choice but to roll my own. The end result is quite acceptable:

And, the whole reason for doing this, here's how it looks on Linux (I'm using a VM of the OSGeo Live DVD, which comes with Mono 2.4)

Aside from some visual bugs due to Mono's implementation of WinForms, the two are essentially visually and functionally identical. Mission accomplished!

Now what's this thing at the bottom?

One of my design goals of FDO Toolbox and Maestro 3.0 is for the application to be as transparent as possible, you should be able to have a good guess at what is happening behind the scenes as you do anything. Thus if something goes wrong, you should have a good log of what had happened.

The Outbound Requests view lets you see all the outbound http requests that Maestro is making to the mapagent endpoint. It's a very useful diagnostic tool. The Messages tab displays any other diagnostic or debugging messages that Maestro may show.

The Site Explorer.

In the previous version of Maestro, the Site Explorer was based on the standard TreeView component. Though it is mostly functional for our needs it had one very annoying limitation: You could only select one item at a time.

For this version of Maestro, the Site Explorer is now based on the TreeViewAdv control. The TreeViewAdv gives us the the multi-selection that we desire and works in Mono (there's Win32 P/Invokes, but they are only used for profiling performance and not in the main code). So win win!

So with multi-selection now available to us, it means we can have different context menus for different selection scenarios. Here's the current context menu for a single selected resource

If you're wondering what Repoint this resource does, it's a feature suggested by Jason Birch which lets you specify all resources referencing the current resource, to reference another resource of your choice instead.

If we selected multiple resources, we get something different.

If you're wondering what Migrate Resources does, it's another feature suggested by Jason which lets you move or copy the selected resources to another MapGuide Server. This function currently doesn't handle resource version compatibility when moving/copying to an older MapGuide Server. It will naively assume the target MapGuide Server supports the versions of the resources you are moving/copying over.

As you can see, this is an untapped design space that has been made open as a result of being able to select multiple items at once. Expect more time-saving commands in future releases as a result.

While we're on the time-saving front, the Site Explorer also supports drag and drop of many different items. Here's some of the things you can drag and drop in Maestro 3.0:
  • Drag and drop a SDF file to create a SDF feature source at the location you dropped the file. The file is embedded into the feature source.
  • Drag and drop a SHP file to create a SHP feature source at the location you dropped the file. Any related files will also be brought in. The files are embedded into the feature source.
  • Drag and drop a SQLite file to create a SQLite feature source at the location you dropped the file. The file is embedded into the feature source.
  • Drag and drop a MGP file to load the package.
  • Drag and drop a XML file to create a resource (based on the content of the XML file) at the location you dropped the file.
Applying the Unix Philosophy

The Unix Philosophy can be summarised as: Write programs that do one thing, and do it well.

Though Maestro is primarily an authoring application for MapGuide, it's core can be re-used and re-purposed for many specialized needs due to the vast array of functionality and services exposed by the MapGuide Server. You have already seen this in action in the previous version with the MgCooker tile generator. We have taken this approach further in this version with a whole bunch of little specialized tools:

The Feature Source Preview Tool

Use this to do FDO Toolbox style data queries on any MapGuide Feature Source

The MapGuide Server Monitor

Use this to observe the current Server statistics as reported by the MapGuide Server

The Feature Source Cache Viewer

Use this to view the state of the Feature Source cache, and find out what connections are currently in use.

All these tools (including MgCooker) are available under the Tools application menu.

That's all for part 1. Stay tuned for part 2!

Wednesday, 9 March 2011

Announcing: MapGuide Maestro 3.0 beta 1

After 10 months of on again, off again development, the next version of MapGuide Maestro is finally here in beta form, if you're brave enough to try it out.

The amount of changes since version 2.1 is way too much for one blog post to contain.

Apart from a completely new user interface, Here's a high-level summary of changes:
I'll be posting a series of posts to provide a "visual walkthrough" of all the new features, bells and whistles, because nothing is better than showing new features through screenshots (lots of screenshots!)

You can download the beta (zip or installer) from the Maestro homepage. The beta will not clash with previous releases of Maestro. You can install the beta side-by-side with your existing installation.