-
-function addObjectToMap(object, map, options) {
- if (objectLoader) objectLoader.abort();
- if (objectLayer) map.removeLayer(objectLayer);
-
- objectLoader = $.ajax({
- url: OSM.apiUrl(object),
- dataType: "xml",
- success: function (xml) {
- objectLayer = new L.OSM.DataLayer(null, {
- styles: {
- node: options.style,
- way: options.style,
- area: options.style
- }
- });
-
- 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;
- }
- };
-
- objectLayer.addData(xml);
-
- if (options.zoom) map.fitBounds(objectLayer.getBounds());
- if (options.callback) options.callback(objectLayer.getBounds());
-
- objectLayer.addTo(map);
- }
- });
-}