[OpenLayers-Users] identifying map regions/features on
the client side
Graham Carlyle
graham.carlyle at maplecroft.com
Fri Apr 11 11:51:28 EDT 2008
Ah excellent.. this seems to be a 2.6 bit of functionality, time to
check out the release candidate!
thanks,
Graham
On Fri, 2008-04-11 at 11:16 -0400, Christopher Schmidt wrote:
> On Fri, Apr 11, 2008 at 04:09:35PM +0100, Graham Carlyle wrote:
> > So I'm thinking a new layer type might provide this which would use much
> > the same info as a vector layer uses (GML, KML etc.) but instead of
> > rendering this vector info it would provide methods to identify the
> > feature at an x,y location.
>
> You don't even need a layer.
>
> 1. When your application loads, load your country data into the client,
> using Format.GML, Format.GeoJSON, etc. Even in relatively slow browsers,
> this is probably only a few seconds of time.
>
> 2. When a user hovers, do a:
>
> var selectedCountry = null;
> var g = new OpenLayers.Geometry.Point(x, y);
> for (var i=0; i < myFeatureList.length; i++) {
> if (myFeatureList[i].geometry.intersects(g)) {
> selectedCountry = myFeatureList[i].attributes.country_code;
> }
> }
>
> Then display your information.
>
> Regards,
More information about the Users
mailing list