[mapserver-users] Re: interesting thread on JSON-ish output from MapServer

Cristiano Sumariva sumariva at gmail.com
Mon Sep 12 08:28:52 EDT 2011


Why do this the hard way? Mapserver now can generate KML output.
Just create a KMLLayer on google maps API an it will do all for you.

The KMLlayer do the ajax request for you, setup the click handler on Map,
setup the infoWindow events all in a two line call, support all simple
features geometry types for vector data.

On mapserver side, setup the kml layer, bind an attribute to the kml name
attribute that will de the infowWindow header.
For additional text on info window you can instruct mapserver to assembly an
HTML template to the kml description attribute.
? Can someone put an layer example for this case ?

Check out KML sample builder for details
http://kml-samples.googlecode.com/svn/trunk/interactive/index.html

and Mapserver
http://mapserver.org/output/kml_output.html

and Maps API KML
http://code.google.com/intl/pt-BR/apis/maps/documentation/javascript/reference.html#KmlLayer

If mapserver options do not meet your requires is very easy to create KML
without Mapserver at all.
The problem now is turning into to force mapserver do what google requires.
If mapserver is becoming hard to do it, you make your logic without it.


2011/9/12 Steve Lime <sdlime at gmail.com>

> The forward could be to a JavaScript file with an empty object. Browser
> should follow ok...
>
> Sent from my iPad
>
> On Sep 11, 2011, at 4:58 PM, Mr. Puneet Kishor <punk.kish at gmail.com>
> wrote:
>
> >
> > On Sep 11, 2011, at 4:18 PM, Steve Lime wrote:
> >
> >> You could try the web object and the empty parameter.
> >
> >
> > From TFM
> >
> > EMPTY [url]
> > URL to forward users to if a query fails. If not defined the value for
> ERROR is used.
> >
> >
> > Hmmmm... I am not sure I want to forward the user to any URL. This is all
> Ajax, so I have to receive an empty data structure. I guess I could try
> exploiting the jQuery `$.ajax({ error: function() { popup an infowindow with
> regrets message } });`
> >
> >
> >
> >
> >>
> >> Sent from my iPad
> >>
> >> On Sep 11, 2011, at 1:33 PM, "Mr. Puneet Kishor" <punk.kish at gmail.com>
> wrote:
> >>
> >>>
> >>> On Sep 11, 2011, at 12:46 PM, Steve Lime wrote:
> >>>
> >>>>
> >>>>
> >>>> Sent from my iPad
> >>>>
> >>>> On Sep 11, 2011, at 9:36 AM, Mr. Puneet Kishor <punk.kish at gmail.com>
> wrote:
> >>>>
> >>>>> Partial solution (phew, for now), but other problems persist --
> >>>>>
> >>>
> >>> ..
> >>>
> >>>>>
> >>>>>
> >>>>> One issue I have not solved -- if no result is found, MapServer sends
> back the following --
> >>>>>
> >>>>> ----
> >>>>> <HTML>
> >>>>>
> >>>>> <HEAD><TITLE>MapServer Message</TITLE></HEAD>
> >>>>>
> >>>>> <!-- MapServer version 6.0.1 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG
> SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=ICONV
> SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=GEOS INPUT=POSTGIS
> INPUT=GDAL INPUT
> >>>>> =SHAPEFILE -->
> >>>>>
> >>>>> <BODY BGCOLOR="#FFFFFF">
> >>>>>
> >>>>> msQueryByPoint(): Search returned no results. No matching record(s)
> found.
> >>>>>
> >>>>> </BODY></HTML>
> >>>>> ----
> >>>>>
> >>>>>
> >>>>> Well, that gums up the works. I really want MapServer to just send an
> empty JSON structure, something like foo({}). Suggestions on how I can
> prevent this HTML message from MapServer, and force it to use the template
> instead?
> >>>
> >>>
> >>> Any suggestion for the above? That is, force MapServer to not send back
> an error message of the above kind. Instead, send back an empty JSON
> structure based on the template?
> >>>
> >>>
> >>> Puneet.
> >
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20110912/d7322ed9/attachment.html


More information about the mapserver-users mailing list