Closed (fixed)
Project:
Openlayers
Version:
6.x-1.x-dev
Component:
OpenLayers Layers
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
8 Oct 2009 at 04:35 UTC
Updated:
2 Dec 2009 at 23:35 UTC
Continued thanks for everyone's work and help on this module!
I'm trying to have two points interact using the distanceTo() function in openlayers, but I can't seem to figure out what the polygons/features are named when created by cck and rendered in a views map.
Could someone help me with this? I'd like to do something like this:
var dist = firstPoint.distanceTo(secondPoint);
alert(dist);
This would be where firstPoint is known and secondPoint is whatever the point that's pulled from the cck field shown in views. I guess the question is 'What is the naming scheme for secondPoint if one or more features are rendered on the map?'
I hope this makes sense. Thanks for any help available.
Comments
Comment #1
apt94jesse commentedHopefully I've answered (at least part of) my own dumb question. While viewing the source of the page where the map is rendered, I get map (and layer) info. My preset is called "mapview" and I get the following regarding layers:
I assume that the "openlayers_views_layer_mapview" is the accurate name in case I want to manually do something like:
I haven't tested it but it would make sense that this this the case (though I've never seen underscores in any of the layer examples I've come across... not sure if that would cause a problem).
However, that source is still a little confusing when I try to figure out the names of the features that cck is adding. The closest I can tell is that it takes the node title field. So if I had a node with a cck wkt field where the node title is maptest, then the actual code needed to add this wkt point/polygon would be
I guess I'm just wanting confirmation or someone to call me stupid and correct me :)
Thanks.
Comment #2
phayes commentedHey,
names are not declared globally, they are stored in the OL object. I find firebug is pretty much the best thing around for exploring javascript objects. If you go to your firebug console and type "OL" (sans quotes - all uppercase), you should get the JS object that contains all the map definitions, as well as the active map objects you want to work with.
So you should find your features in something like this: OL.maps['yourmapnamehere'].layers['yourlayernamehere'].features
Comment #3
zzolo commentedClosing, no feedback in two months.