AW: [OpenLayers-Users] new OpenLayers.Format.OSM and
functiononFeatureSelect(feature)
Arnd Wippermann
arnd.wippermann at web.de
Wed Nov 9 15:44:55 EST 2011
Hi,
You can try to extent the function getTags
to add the attributes of the node as attributes to the feature.
I don't know, if it's the right way, but it works.
Arnd
..\OpenLayers-2.10\lib\OpenLayers\Format\OSM.js
/**
* Method: getTags
* Return the tags list attached to a specific DOM element.
*
* Parameters:
* node - {DOMElement} node to parse tags from
* interesting_tags - {Boolean} whether the return from this function
should
* return a boolean indicating that it has 'interesting tags' --
* tags like attribution and source are ignored. (To change the list
* of tags, see interestingTagsExclude)
*
* Returns:
* tags - {Object} hash of tags
* interesting - {Boolean} if interesting_tags is passed, returns
* whether there are any interesting tags on this element.
*/
OpenLayers.Format.OSM.prototype.getTags = function(dom_node,
interesting_tags) {
var tag_list = dom_node.getElementsByTagName("tag");
var tags = {};
var interesting = false;
for (var j = 0; j < tag_list.length; j++) {
var key = tag_list[j].getAttribute("k");
tags[key] = tag_list[j].getAttribute("v");
if (interesting_tags) {
if (!this.interestingTagsExclude[key]) {
interesting = true;
}
}
}
tags["user"] = dom_node.getAttribute("user");
tags["timestamp"] = dom_node.getAttribute("timestamp");
tags["timestamp"] = dom_node.getAttribute("timestamp");
tags["changeset"] = dom_node.getAttribute("changeset");
tags["uid"] = dom_node.getAttribute("uid");
tags["version"] = dom_node.getAttribute("version");
return interesting_tags ? [tags, interesting] : tags;
};
-----Ursprüngliche Nachricht-----
Von: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] Im Auftrag von ph ttv
Gesendet: Mittwoch, 9. November 2011 10:09
An: users at openlayers.org
Betreff: [OpenLayers-Users] new OpenLayers.Format.OSM and
functiononFeatureSelect(feature)
Hi all,
I do not know find documentation, simple and illustrated with examples where
I can fill my tooltip, and therefore I expose you my problem below:
Indeed, I try to get various information about a node in order to view them
in a tooltip, using "onFeatureSelect function (feature)."
If my crafts night allowed me to obtain, for example, the name of the node
(with feature.attributes.name) or the id of the node
(feature.osm_id) but :
-----------------------------------------------------------------------
how to extract the information "user" or even the date of last update
("timestamp")?
------------------------------------------------------------------------
I have run out of ... strategy (s) ...
(The file format is osm: format: new OpenLayers.Format.OSM ())
my last test is here: http://mdl29.net/0j
and my data file. osm looks like this:
<node id="278511438" lat="47.9356738" lon="-4.0211462" version="2"
timestamp="2011-04-03T12:06:59Z" changeset="7753311" uid="155442"
user="FPH">
<tag k="amenity" v="recycling"/>
<tag k="recycling:clothes" v="no"/>
<tag k="recycling:glass" v="yes"/>
<tag k="recycling:paper" v="yes"/>
</node>
Thanks for your help !
Titivi
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users
More information about the Users
mailing list