2 L.extend(L.LatLngBounds.prototype, {
4 return (this._northEast.lat - this._southWest.lat) *
5 (this._northEast.lng - this._southWest.lng);
9 return new L.LatLngBounds(this._southWest.wrap(), this._northEast.wrap());
13 L.Icon.Default.imagePath = <%= "#{asset_prefix}/images".to_json %>;
18 function mapLayers() {
25 name: I18n.t("javascripts.map.base.standard")
28 klass: L.OSM.CycleMap,
29 attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
32 name: I18n.t("javascripts.map.base.cycle_map")
35 klass: L.OSM.TransportMap,
36 attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
37 keyid: "transportmap",
39 name: I18n.t("javascripts.map.base.transport_map")
42 klass: L.OSM.MapQuestOpen,
43 attribution: "Tiles courtesy of <a href='http://www.mapquest.com/' target='_blank'>MapQuest</a> <img src='http://developer.mapquest.com/content/osm/mq_logo.png'>",
46 name: I18n.t("javascripts.map.base.mapquest")
51 function getUserIcon(url) {
53 iconUrl: url || <%= asset_path('marker-red.png').to_json %>,
56 popupAnchor: [1, -34],
57 shadowUrl: <%= asset_path('images/marker-shadow.png').to_json %>,
62 function addObjectToMap(object, map, options) {
68 map.removeLayer(objectLayer);
71 objectLoader = $.ajax({
72 url: OSM.apiUrl(object),
74 success: function (xml) {
75 objectLayer = new L.OSM.DataLayer(null, {
83 objectLayer.interestingNode = function (node, ways, relations) {
84 if (object.type === "node") {
86 } else if (object.type === "relation") {
87 for (var i = 0; i < relations.length; i++)
88 if (relations[i].members.indexOf(node) != -1)
95 objectLayer.addData(xml);
97 var bounds = objectLayer.getBounds();
100 map.fitBounds(bounds);
103 if (options.callback) {
104 options.callback(bounds);
107 objectLayer.addTo(map);