javascript - bug with database values in leaflet pop ups -
i building project using leaflet , meteor user can enter text , have text displayed in popup when click on map. can text display initially, text display lost on refresh.
var markers = new meteor.collection('markers'); meteor.subscribe('markers'); template.map.rendered = function() { map = l.map('map', {doubleclickzoom: false}).locate({setview: true, maxzoom: 16}); //adds markers on dblclick map.on('dblclick', function(event) { currentlatlng = event.latlng; markers.insert({latlng: event.latlng}); }); var query = markers.find(); query.observe({ added: function (document) { var marker = l.marker(document.latlng).addto(map) .on('dblclick', function(event) { map.removelayer(marker); markers.remove({_id: document._id}); }); //display user input in popup var value; value = $("#txt_name").val(); markers.insert({txt: value}); marker.bindpopup(markers.findone({txt: value}).txt).openpopup(); } );//end observe }
i know because on refresh, value
(which text field in html) blank, won't return anything. how can have display corresponding database field? way i've done far using {{handlebars}}
in html, doesn't seem possible leaflet popups.
the txt
different document latlng
& 2 not related in way in db. when create new marker, need include txt
. few exceptions, should focus on making every document within markers collection follow same schema.
Comments
Post a Comment