A couple of Ruby/Rails GIS notes
I am adding some simple GIS stuff into my Rails app today.
Cartographer: Google Maps Helpers for Ruby on Rails looks like a pretty good plugin to add a map into your codebase. I'll see how it goes...
The MetaCarta Geoparser API has also been wrapped by the robot co-op guys. I am really liking the approach taken by the new MetaCarta Labs stuff. In particular, I like the REST over SOAP approach. The number of lines of code required for SOAP is just ridiculous in proportion to the benefit gained. One of my guys was working with their SOAP interface this morning, and while SOAP4R's WSDL2RB script is the way to go (it's kind of like AXIS for Ruby)...it's just not necessary for what we're doing.
I am sorta disappointed that the KML support for Google Maps requires a public website to host the KML so that it can be parsed out on their server. I guess it's just too much to process in the JavaScript?
3 comments:
It's costly to develop a javascript KML parser because js development tools are so weak compared to those for languages on the server side. Mapbuilder has some GML parsing capability, but it must have been a pains-taking effort.
Agreed...they did provide this thing, the Gxml parser. I suppose it would be rather simple to write something like the following example for KML.
// Download the data in data.xml and load it on the map. The format we
// expect is:
// <markers>
// <marker lat="37.441" lng="-122.141"/>
// <marker lat="37.322" lng="-121.213"/>
// </markers>
GDownloadUrl("data.xml", function(data, responseCode) {
var xml = GXml.parse(data);
var markers = xml.documentElement.getElementsByTagName("marker");
for (var i = 0; i < markers.length; i++) {
var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
map.addOverlay(new GMarker(point));
}
});
Post a Comment