I have a requirement for users to be able to select a point within a state within the US on a map (which would be an openlayers web application) and once they clicked on the map it would derive the following: a.) the latitude and longitude of the point that was clicked on the map b.) the county that contained this click point

What possible ways could the above be implemented?


You would have to set up some sort of service or polygon layer for the US counties. One possible solution (if you don't have your own US counties data) is to find a public WFS or WMS service. Here's one that doesn't contain counties, but is a good example of how you'd do it using OpenLayers.

Also helpful if by chance you're mapping fire stations in Medford, Oregon ;).

Here's a public US counties boundary WMS, but I couldn't get it to work.

Here's another example on the OpenLayers examples page: http://dev.openlayers.org/releases/OpenLayers-2.12/examples/getfeatureinfo-popup.html

If you're using your own data and don't want to make a WMS out of it, I think you could do something similar with KML. I'm not terribly sure of that, however.

Yet another possible implementation would involve PostGIS and some simple spatial queries, but I'm not sure whether that's even feasible for your setup.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.