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) {
67 map.removeLayer(objectLayer);
70 objectLoader = $.ajax({
71 url: OSM.apiUrl(object),
73 success: function (xml) {
74 objectLayer = new L.OSM.DataLayer(null, {
82 objectLayer.interestingNode = function (node, ways, relations) {
83 if (object.type === "node") {
85 } else if (object.type === "relation") {
86 for (var i = 0; i < relations.length; i++)
87 if (relations[i].members.indexOf(node) != -1)
94 objectLayer.addData(xml);
96 var bounds = objectLayer.getBounds();
99 map.fitBounds(bounds);
102 if (options.callback) {
103 options.callback(bounds);
106 objectLayer.addTo(map);