[OSM-dev] More points on Leaflet map

Giuseppe Ricci peppepegasus at gmail.com
Sat Apr 12 14:11:13 UTC 2014


Hi guys,

I'm new on OSM and, in particular, with Leaflet. I have some problem to
create a map with more points/markers: I have an array (a matrix) where I
have latitude, longitude and description. I have 50 points of interest to
show on the map.
I use for 1 point this code:

<div id="map">
        <style>
        #map { height: 500px; }
        </style>
        <script type="text/javascript">
        var map = L.map('map').setView([<? echo $dati[1][5]; ?>, <? echo
$dati[1][6];?>], 9);
//        var map = L.map('map').setView([40.784027, 17.238874], 15);
// 41.133333, 16.85

        L.tileLayer('http://{s}.
tile.cloudmade.com/88ed710d6b7e41d2aad93a3cce1e10d3/997/256/{z}/{x}/{y}.png',
{
            attribution: 'Map data © <a
href="http://openstreetmap.org">OpenStreetMap</a>
contributors, <a
href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>,
Imagery © <a href="http://cloudmade.com">CloudMade</a>',
            maxZoom: 18
        }).addTo(map);
        var marker = L.marker([<? echo $dati[1][5]; ?>, <? echo
$dati[1][6]; ?>]).addTo(map);
 //       marker.bindPopup("<b><? echo $dati[1][2]; ?></b><br><? echo
$dati[1][3]; ?>").openPopup();
        marker.bindPopup("<b><? echo $dati[1][2]; ?></b><br><? echo
$dati[1][7]; ?>").openPopup();
        </script>
</div>

as suggested in Leaflet Quick Start Guide. If I want to show 50 points
(stored in $dati matrix), what code can I use?
I realized if the description to show in the popup is  long, Leaflet don't
creates the map, how can I solve this problem?
I'm using PHP.
Thanks.
Giuseppe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20140412/e34f7728/attachment.html>


More information about the dev mailing list