MapGuide OS with Google Earth

Jason Birch Jason.Birch at
Mon Apr 10 12:36:36 EDT 2006

Something that I've recently figured out is that it's a lot easier to
debug Mg errors if you wrap your code in Try/Catch.  Have a look at some
of the code in the mapadmin area, or in the package command line
utilities I posted about yesterday.
I wonder if the geometry column for your data source is the same as the
sample data (SHPGEOM).

You can see what this is supposed to be by looking at a layer based on
that feature source in Studio, under "Feature Data Setup".  You can also
get this information by going into the mapagent/index.html file,
clicking on Feature Service API in the upper left, then clicking on
Describe Feature item, and finally fill in the FeatureSource ID 
The sample data definition looks like this:
  <xs:complexType name="HydrographicPolygonsType" abstract="false"
The fdo:geometryName attribute is what you want here.  
A better solution would be to let the code extract the geometry
column... hmm... bit of research later:
You could replace this line:
  $byteReader = $featureReader->GetGeometry('SHPGEOM');

With this:
  $byteReader =

Note that this isn't very efficient; it checks the default geometry
property on each feature object.  It would be better to do this outside
of the loop, or at the top of the loop in a section that's only executed


From: Willem Schwarte [mailto:willem at] 
Sent: Monday, April 10, 2006 07:38
To: Jason Birch
Cc: users at
Subject: RE: MapGuide OS with Google Earth



I have tried your sample for Google Earth, and it work fine with the
sheybogan sample data.


If I paste this in my internet Explorer
<http://localhost/sites/google_earth/water.php>  I will get a bunch of


But when I try to use my own data I get an error:


PHP Fatal error: Uncaught exception 'mgobjectnotfoundexception' in
Unknown on line 0


In the water.php file I change this line like so:


$featureReader = $featureService->SelectFeatures(new
FeatureSource"), "totaal_tvg32010101_v", null);


As you can see in XML below, this does exist.  Do you might know why I
don't get anything ?












1##>  <ResourceDocumentHeader

1##>  <General>



1##>  <Security


1##>  <Groups>

1##>  <Group>











Van: Jason Birch [mailto:Jason.Birch at] 
Verzonden: dinsdag 14 maart 2006 8:19
Aan: users at
Onderwerp: MapGuide OS with Google Earth


I've uploaded a pretty basic example of using MapGuide OS to serve KML
to Google Earth, based on an example that Bob Bray provided with the
first preview:


This is totally unsupported, but in my experience it works with the
Sheboygan data set.  On a standard Windows/Apache/Php install you should
just have to follow the instructions in the readme.txt file.


I had a better example that worked to return data for the current
bounding box (you can see it in action at ) but
I was unable to get this working with the sample data, so either
something has changed with 1.0 or the sample data is different somehow
than what I'm serving.  I didn't get any error messages, but seeing all
of the exception codes in the API, I guess I should be trapping for
these somehow.  Not enough time to research now though.


My to-do list:

- clean up the code, make it more modular, and possibly use TJ's
KMLDocument class for generating the KML:

- figure out how to read the default scale ranges and symbology from
MapGuide, and return a semblance of those instead of having to custom
code each layer.  

- dynamically rewrite the bounding box, so that it shifts to the
foreground when the view is tilted, allowing delivery of data without
killing the server with a huge extent

- deliver GroundOverlay images as an option for small-scale mapping
where serving vectors is inappropriate


Of course Autodesk could just step in any time now and provide a
template for default delivery of KML :)




-------------- next part --------------
An HTML attachment was scrubbed...

More information about the Mapguide-users mailing list