@@ -24,6 +24,7 @@ $(document).ready(function () {
24
24
25
25
var noteLayer = new L . LayerGroup ( ) ;
26
26
var notes = { } ;
27
+ var newNote ;
27
28
28
29
map . on ( "layeradd" , function ( e ) {
29
30
if ( e . layer == noteLayer ) {
@@ -39,6 +40,14 @@ $(document).ready(function () {
39
40
}
40
41
} ) ;
41
42
43
+ map . on ( "popupclose" , function ( e ) {
44
+ if ( e . popup == newNote . _popup ) {
45
+ $ ( newNote ) . oneTime ( 10 , "removenote" , function ( ) {
46
+ map . removeLayer ( newNote ) ;
47
+ } ) ;
48
+ }
49
+ } ) ;
50
+
42
51
if ( OSM . STATUS != 'api_offline' && OSM . STATUS != 'database_offline' ) {
43
52
map . layersControl . addOverlay ( noteLayer , I18n . t ( "browse.start_rjs.notes_layer_name" ) ) ;
44
53
@@ -217,7 +226,7 @@ $(document).ready(function () {
217
226
markerPosition = [ mapSize . x / 2 , mapSize . y ] ;
218
227
}
219
228
220
- var marker = L . marker ( map . containerPointToLatLng ( markerPosition ) , {
229
+ newNote = L . marker ( map . containerPointToLatLng ( markerPosition ) , {
221
230
icon : noteIcons [ "new" ] ,
222
231
opacity : 0.7 ,
223
232
draggable : true
@@ -237,18 +246,20 @@ $(document).ready(function () {
237
246
238
247
popupContent . find ( "input[type=submit]" ) . on ( "click" , function ( e ) {
239
248
e . preventDefault ( ) ;
240
- createNote ( marker , e . target . form , $ ( e . target ) . data ( "url" ) ) ;
249
+ createNote ( newNote , e . target . form , $ ( e . target ) . data ( "url" ) ) ;
241
250
} ) ;
242
251
243
- marker . addTo ( noteLayer ) . bindPopup ( popupContent [ 0 ] , popupOptions ( ) ) . openPopup ( ) ;
244
-
245
- $ ( ".leaflet-popup-close-button" ) . on ( "click.close" , function ( e ) {
246
- map . removeLayer ( marker ) ;
252
+ newNote . addTo ( noteLayer ) . bindPopup ( popupContent [ 0 ] , popupOptions ( ) ) . openPopup ( ) ;
247
253
254
+ newNote . on ( "remove" , function ( e ) {
248
255
$ ( "#createnoteanchor" ) . removeClass ( "disabled" ) . addClass ( "geolink" ) ;
249
256
} ) ;
250
257
251
- marker . on ( "dragend" , function ( e ) {
258
+ newNote . on ( "dragstart" , function ( e ) {
259
+ $ ( newNote ) . stopTime ( "removenote" ) ;
260
+ } ) ;
261
+
262
+ newNote . on ( "dragend" , function ( e ) {
252
263
e . target . openPopup ( ) ;
253
264
} ) ;
254
265
} ) ;
0 commit comments