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({
25 name: I18n.t("javascripts.map.base.standard")
27 layer: new L.OSM.CycleMap( {
28 attribution: "Tiles courtesy of <a href='http://www.opencyclemap.org/' target='_blank'>Andy Allan</a>",
32 name: I18n.t("javascripts.map.base.cycle_map")
34 layer: new L.OSM.TransportMap({
35 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")
41 layer: new L.OSM.MapQuestOpen({
42 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")
50 function getUserIcon(url) {
52 iconUrl: url || <%= asset_path('marker-red.png').to_json %>,
55 popupAnchor: [1, -34],
56 shadowUrl: <%= asset_path('images/marker-shadow.png').to_json %>,
61 function addObjectToMap(object, map, options) {
62 if (objectLoader) objectLoader.abort();
63 if (objectLayer) map.removeLayer(objectLayer);
65 objectLoader = $.ajax({
66 url: OSM.apiUrl(object),
68 success: function (xml) {
69 objectLayer = new L.OSM.DataLayer(null, {
77 objectLayer.interestingNode = function (node, ways, relations) {
78 if (object.type === "node") {
80 } else if (object.type === "relation") {
81 for (var i = 0; i < relations.length; i++)
82 if (relations[i].members.indexOf(node) != -1)
89 objectLayer.addData(xml);
91 if (options.zoom) map.fitBounds(objectLayer.getBounds());
92 if (options.callback) options.callback(objectLayer.getBounds());
94 objectLayer.addTo(map);