Home Create JavaScript element within razor foreach loop
Reply: 0

Create JavaScript element within razor foreach loop

user666
1#
user666 Published in May 21, 2018, 12:50 pm

I'm adding the results of a search to a map using OpenStreetMap. For each returned search result, I need to plot the latitude and longitude on a map as such:

L.marker([39.616886,-86.310997]).addTo(map)
.bindPopup('the institutions name')
.openPopup();

How do I do that within a forEach loop? Here's what I attempted, but I'm getting an error:

The name L doesn't exist in the current context.

@foreach (var u in Model.listschools)
{
    L.marker([@u.lat, @u.longt]).addTo(map)
        .bindPopup(@u.instnm)
    .openPopup();
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.323249 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO