Skip to main content
Commonmark migration
Source Link

You need to set a listener for the mouseover event. The [markers][1]markers page lists a "mouseover" event, and the [events][2]events page shows how to configure a listener. So the code will be something like:

city1.on('mouseover', function(e) {
  //open popup;
  var popup = L.popup()
    .setLatLng(e.latlng) //(assuming e.latlng returns the coordinates of the event)
    .setContent('<p>Hello world!<br />This is a nice popup.</p>')
    .openOn(map);
});

(Note that I haven't actually tested that, so view it as pseudo-code)

Steve [1]: http://leaflet.cloudmade.com/reference.html#marker [2]: http://leaflet.cloudmade.com/reference.html#events

You need to set a listener for the mouseover event. The [markers][1] page lists a "mouseover" event, and the [events][2] page shows how to configure a listener. So the code will be something like:

city1.on('mouseover', function(e) {
  //open popup;
  var popup = L.popup()
    .setLatLng(e.latlng) //(assuming e.latlng returns the coordinates of the event)
    .setContent('<p>Hello world!<br />This is a nice popup.</p>')
    .openOn(map);
});

(Note that I haven't actually tested that, so view it as pseudo-code)

Steve [1]: http://leaflet.cloudmade.com/reference.html#marker [2]: http://leaflet.cloudmade.com/reference.html#events

You need to set a listener for the mouseover event. The markers page lists a "mouseover" event, and the events page shows how to configure a listener. So the code will be something like:

city1.on('mouseover', function(e) {
  //open popup;
  var popup = L.popup()
    .setLatLng(e.latlng) //(assuming e.latlng returns the coordinates of the event)
    .setContent('<p>Hello world!<br />This is a nice popup.</p>')
    .openOn(map);
});

(Note that I haven't actually tested that, so view it as pseudo-code)

Steve

Source Link
Stephen Lead
  • 21.2k
  • 18
  • 114
  • 241

You need to set a listener for the mouseover event. The [markers][1] page lists a "mouseover" event, and the [events][2] page shows how to configure a listener. So the code will be something like:

city1.on('mouseover', function(e) {
  //open popup;
  var popup = L.popup()
    .setLatLng(e.latlng) //(assuming e.latlng returns the coordinates of the event)
    .setContent('<p>Hello world!<br />This is a nice popup.</p>')
    .openOn(map);
});

(Note that I haven't actually tested that, so view it as pseudo-code)

Steve [1]: http://leaflet.cloudmade.com/reference.html#marker [2]: http://leaflet.cloudmade.com/reference.html#events