|
26 | 26 | scrollWheelZoom : true, |
27 | 27 | worldCopyJump: true, |
28 | 28 | contextmenu: false |
29 | | - } |
| 29 | + }, |
| 30 | + formid: false |
30 | 31 | }; |
31 | 32 |
|
32 | 33 | // The actual plugin constructor |
|
74 | 75 | var popup = window.L.popup(); |
75 | 76 |
|
76 | 77 | function onMapClick(e) { |
77 | | - console.log(e.latlng.toString()); |
78 | | - console.log(document.forms); |
| 78 | + //console.log(e.latlng.toString()); |
| 79 | + //console.log(document.forms); |
| 80 | + //console.log(this.options); |
79 | 81 | popup |
80 | 82 | .setLatLng(e.latlng) |
81 | 83 | .setContent("You clicked the map at " + e.latlng.toString()) |
82 | 84 | .openOn(this.map); |
83 | | - var form=document.forms[1] |
84 | | - form.osmlat.value = Math.ceil(e.latlng.lat * 100000) / 100000; |
85 | | - form.osmlon.value = Math.ceil(e.latlng.lng * 100000) / 100000; |
| 85 | + |
| 86 | + if(this.options.formid != false) { // Batch manager single mode |
| 87 | + $('[name=osmlat-'+this.options.formid+']').val(Math.ceil(e.latlng.lat * 100000) / 100000); |
| 88 | + $('[name=osmlon-'+this.options.formid+']').val(Math.ceil(e.latlng.lng * 100000) / 100000); |
| 89 | + } else { // Batch manager global mode |
| 90 | + var form=document.forms[1]; |
| 91 | + form.osmlat.value = Math.ceil(e.latlng.lat * 100000) / 100000; |
| 92 | + form.osmlon.value = Math.ceil(e.latlng.lng * 100000) / 100000; |
| 93 | + } |
86 | 94 | } |
87 | 95 |
|
88 | 96 | this.map.on('click', onMapClick, this); |
|
119 | 127 |
|
120 | 128 | init : function() { |
121 | 129 | this.id = this.element.attr('id'); |
122 | | - //add id if necessart |
| 130 | + //add id if necessary |
123 | 131 | if(!this.id) { |
124 | 132 | this.id = 'leafletmap' + Math.floor((Math.random()*100)+1); |
125 | 133 | this.element.attr('id', this.id); |
126 | 134 | } |
127 | 135 | // get data from data attributes in html |
128 | 136 | // set markers for each map |
129 | 137 | // other options are shared |
130 | | - if(typeof this.element.data('markerpos') != 'undefined' && this.element.data('markerpos').length != 0) { |
| 138 | + if(typeof this.element.data('markerpos') != 'undefined' && this.element.data('markerpos').length > 1) { |
131 | 139 | this.element.markers = []; |
132 | 140 | this.element.markers.push({ |
133 | 141 | pos : this.element.data('markerpos').split(','), |
134 | 142 | text: this.element.data('markertext') |
135 | 143 | }); |
| 144 | + this.options.mapOptions.zoom = 15; // If position is set then zoom into it |
136 | 145 | } else { |
137 | 146 | this.element.markers = this.options.markers; |
138 | 147 | } |
139 | 148 |
|
140 | 149 | // set center |
141 | 150 | if(typeof this.element.data('center') != 'undefined' && this.element.data('center').length != 0) { |
142 | 151 | this.element.center = this.element.data('center').split(','); |
143 | | - } else if (typeof this.element.data('markerpos') != 'undefined' && this.element.data('markerpos').length != 0) { |
| 152 | + } else if (typeof this.element.data('markerpos') != 'undefined' && this.element.data('markerpos').length > 1) { |
144 | 153 | this.element.center = this.element.data('markerpos').split(','); |
145 | 154 | } else { |
146 | 155 | this.element.center = this.options.mapOptions.center; |
147 | 156 | } |
148 | 157 |
|
| 158 | + // formid for batch manager single mode |
| 159 | + if(typeof this.element.data('formid') != 'undefined' && this.element.data('formid').length != 0) { |
| 160 | + this.options.formid = this.element.data('formid'); |
| 161 | + } |
| 162 | + |
149 | 163 | //render |
150 | 164 | this.loadStylesheet(this.options.leafletCssUri); |
151 | 165 | $.getScript(this.options.leafletJsUri, this.bind(this.setMap, this)); |
|
0 commit comments