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(),
23 name: I18n.t("javascripts.map.base.standard")
25 layer: new L.OSM.CycleMap( {
26 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>",
35 keyid: "transportmap",
37 name: I18n.t("javascripts.map.base.transport_map")
39 layer: new L.OSM.MapQuestOpen({
40 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'>",
44 name: I18n.t("javascripts.map.base.mapquest")
48 function getUserIcon(url) {
50 iconUrl: url || <%= asset_path('marker-red.png').to_json %>,
53 popupAnchor: [1, -34],
54 shadowUrl: <%= asset_path('images/marker-shadow.png').to_json %>,
59 function addObjectToMap(object, map, options) {
65 map.removeLayer(objectLayer);
68 objectLoader = $.ajax({
69 url: OSM.apiUrl(object),
71 success: function (xml) {
72 objectLayer = new L.OSM.DataLayer(null, {
80 objectLayer.interestingNode = function (node, ways, relations) {
81 if (object.type === "node") {
83 } else if (object.type === "relation") {
84 for (var i = 0; i < relations.length; i++)
85 if (relations[i].members.indexOf(node) != -1)
92 objectLayer.addData(xml);
94 var bounds = objectLayer.getBounds();
97 map.fitBounds(bounds);
100 if (options.callback) {
101 options.callback(bounds);
104 objectLayer.addTo(map);