On Sep 11, 2011, at 10:03 PM, Richard Greenwood wrote: > On Sun, Sep 11, 2011 at 8:48 AM, Mr. Puneet Kishor <[email protected]> > wrote: >> >> On Sep 11, 2011, at 8:03 AM, Richard Greenwood wrote: >> >>> On Sat, Sep 10, 2011 at 1:35 PM, Mr. Puneet Kishor <[email protected]> >>> wrote: >>>> Now that I have mode=tile working with Google Maps API v3, I am on my way >>>> to implement querying like so >>>> >>>> 0. Bind an infowindow.close() to a click event listener on the map >>>> 1. Bind an infowindow.open() to a click event listener on the MapServer >>>> layer >>>> 2. Fill the infowindow content with the result from an Ajax query to >>>> MapServer >>>> 3. When the user clicks on the MapServer layer, the Ajax query is fired >>>> 4. MapServer responds with the query result as a JSON object >>>> 5. Fill the infowindow with the JSON result >>>> 6. Close any already open infowindow via #0 above >>>> 7. Open a new infowindow with the result >>>> >>>> Is the general approach outlined above sound? Any pointers to existing >>>> code samples for the above? >>> >>> >>> Puneet, >>> >>> I'm doing pretty much that here: >>> http://records.sublettewyo.com/mapserver/map.html >>> I'm using jQuery in this example and putting the info into a jQuery >>> dialog, however I have used a standard browser window in the past. >>> Only thing is that I don't thinnk you really need step 0, simply >>> replace the contents of the container with the new info. >> >> >> Yup, I don't have to worry about #0. Howerver, #1 above is problematic, and >> I don't have a resolution for it yet. Seems like in Google Maps API v3 I >> can't addListener to an ImageMapType overlay. See, I am adding a MapServer >> layer as ImageMapType overlay like so >> >> "mapserverLayer" : new google.maps.ImageMapType({ .. }) >> map.overlayMapTypes.insertAt(0, mapserverLayer); >> >> >> If I do the following -- >> >> google.maps.event.addListener(map, "click", function (event) { } >> >> it works, however, the following doesn't work at all >> >> google.maps.event.addListener(mapserverLayer, "click", function (event) { } >> >> Which is silly, isn't it? I don't want the entire map to be listening to the >> "click" events. I just want the MapServer layer to be doing so. Haven't yet >> found a resolution to this. >> >> >>> >>> Also, if your data is in PostGIS you can skip mapserver for attribute >>> queries and do an info query against the PostGIS db via PHP or other >>> server-side tool. >>> >> >> Ok, I am very interested in the above, but I am not sure I understand you. >> For the most part, I want to click on the map, and find out more about what >> I clicked on. In order to do that query via Perl MapScript (I don't know >> PHP) and Pg, I would need to create the $mapObj. I am able to do that fine, >> but I don't know how to run MapServer in `mode=tile` via MapScript. This is >> the question I have asked a couple of times -- if I have a pure MapScript >> app (no map files involved at all, which is what I want), how no earth do I >> tell the app to use `mode=tile`? >> >> Puneet. >> >> > > Puneet, > > I do not know how to bind an infowindow.open() to a click event > listener on the MapServer layer (#1 above) because I do not use the > Google API. But using Perl, PHP or whatever it is easy to query a > PostGIS database, and even get GeoJSON back should you want to > highlight the selected object on the map. > > I am using OpenLayers so I can easily convert the mouse click (or box) > to a real-world coordinate(s). I pass the point or box to a PHP page > which connects to a PostGIS db, does the query, and returns JSON. Does > that help? I'm not sure that I understand everything that you're doing > and maybe my approach is not appropriate in your case.
I am assuming you are using OL with MapServer WMS. If I could get MapServer WMS (via MapScript) working, it would have been good, but after screwing around for a day and a half unsuccessfully, I gave up (for now). Then I tried `mode=tile` and it just worked. However, even that is not fully satisfactory as it is not via MapScript. Without MapScript I am severely hampered -- the complexity of the datasets makes for beastly map files. My map file with just one data source is already almost 9000 lines long. In fact, I generate the map file via MapScript, and then further tweak it by hand. Even with WMS or tile mode, I will have to implement some kind of tile caching either with tilecache or map proxy or some such to improve the performance. However, since I am not using MapScript (even though I would prefer to), I would have to implement both CGI and MapScript to do what you are suggesting above -- CGI to display the map and MapScript to do the query. For now, I have been able to get this clicky thing working -- I click on the map, do a `mode=query` and display the result in an infowindow. That part is working. Ideally, I would like to have a single technology -- MapScript to generate the maps that can be displayed via multiple front-ends -- OL, Gmaps, perhaps Leaflet, and MapScript to query the attributes via clicks and selects on the map. For now, I am flailing. > > Are you in Denver for FOSS4G?? > Unfortunately no. Too much work here, and no funding to travel. I am sure you all will have a blast. Puneet. _______________________________________________ mapserver-users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/mapserver-users
