-
-function addObjectToMap(object, map, options) {
- if (objectLoader) objectLoader.abort();
- if (map.objectLayer) map.removeLayer(map.objectLayer);
-
- objectLoader = $.ajax({
- url: OSM.apiUrl(object),
- dataType: "xml",
- success: function (xml) {
- map.objectLayer = new L.OSM.DataLayer(null, {
- styles: {
- node: options.style,
- way: options.style,
- area: options.style
- }
- });
-
- map.objectLayer.interestingNode = function (node, ways, relations) {
- if (object.type === "node") {
- return true;
- } else if (object.type === "relation") {
- for (var i = 0; i < relations.length; i++)
- if (relations[i].members.indexOf(node) != -1)
- return true;
- } else {
- return false;
- }
- };
-
- map.objectLayer.addData(xml);
-
- if (options.zoom) map.fitBounds(map.objectLayer.getBounds());
- if (options.callback) options.callback(map.objectLayer.getBounds());
-
- map.objectLayer.addTo(map);
- }
- });
-}