Im close to update markers inside the <script> tags of "Quick Example" but I need help

12 views
Skip to first unread message

Andres Muñoz

unread,
Mar 25, 2015, 1:11:47 PM3/25/15
to leafl...@googlegroups.com
You know there's this example code on leafletjs.com
<script id = "pdis">
window
.onload = function () {
     
var map = L.map('map').setView([-26.40894, -54.67430], 18);
     
    L
.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
        attribution
: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
   
}).addTo(map);

        L
.marker([-26.40893, -54.67438]).addTo(map)
           
.bindPopup("<b>a noticeable point</b><br/>yeah").openPopup();

        L
.marker([-26.40896, -54.67403]).addTo(map)
           
.bindPopup("<b>another noticeable point!</b><br />another yeah").openPopup();

};

</script>

And Im wondering if there's a way to update those L.markers by performing a JQuery's .text() or .html() driven update. What I have at the moment is to make a query in a database and get this:
if(mysql_num_rows($res)==0){

echo
'<b>Nothing matches</b>';

}else{

echo
'<b>Matches:</b><br/>';

while($row=mysql_fetch_array($res)){

echo
'<img src="logo/'.$row['id'].'.jpg"></img><br><em>'.$row['cat'].'</em><br><b>'.$row['name'].'</b><br>'.$row['dir'].'<br><a href="msite/'.$row['id'].'.html" target="_blank">More...</a>';
}


I cant figure out how to use that last echo to update L.markers contents inside the original script.
I have tried .html() with innerHTML and doesnt work, and I think .text() cant work since <Script> doenst seems to get an id="pis" like name...
I think i could make an echo '... database output...' and then .wrap it with <script> tags, but it wouldnt look as pro as I want... so, any suggestion?
Reply all
Reply to author
Forward
0 new messages