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() {
20 layer: new L.OSM.Mapnik(),
24 name: I18n.t("javascripts.map.base.standard")
26 layer: new L.OSM.CycleMap(),
27 attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
30 name: I18n.t("javascripts.map.base.cycle_map")
32 layer: new L.OSM.TransportMap(),
33 attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
34 keyid: "transportmap",
36 name: I18n.t("javascripts.map.base.transport_map")
38 layer: new L.OSM.MapQuestOpen(),
39 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'>",
42 name: I18n.t("javascripts.map.base.mapquest")
46 function getUserIcon(url) {
48 iconUrl: url || <%= asset_path('marker-red.png').to_json %>,
51 popupAnchor: [1, -34],
52 shadowUrl: <%= asset_path('images/marker-shadow.png').to_json %>,
57 function addObjectToMap(object, map, options) {
63 map.removeLayer(objectLayer);
66 objectLoader = $.ajax({
67 url: OSM.apiUrl(object),
69 success: function (xml) {
70 objectLayer = new L.OSM.DataLayer(null, {
78 objectLayer.interestingNode = function (node, ways, relations) {
79 if (object.type === "node") {
81 } else if (object.type === "relation") {
82 for (var i = 0; i < relations.length; i++)
83 if (relations[i].members.indexOf(node) != -1)
90 objectLayer.addData(xml);
92 var bounds = objectLayer.getBounds();
95 map.fitBounds(bounds);
98 if (options.callback) {
99 options.callback(bounds);
102 objectLayer.addTo(map);