Javascript examples for Leaflet:Event
prevent popup showing
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" type="text/css" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"> <script type="text/javascript" src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet-src.js"></script> <style id="compiled-css" type="text/css"> #map {/*from ww w . j a v a2 s. co m*/ height: 400px; } </style> <script type="text/javascript"> window.onload=function(){ var lat = 50.91; var lng = 1.38; var zoom = 5; var map = new L.Map('map'); var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; var osmAttrib = 'Map data © OpenStreetMap contributors'; var osm = new L.TileLayer(osmUrl, { minZoom: 3, maxZoom: 8, attribution: osmAttrib }); map.addLayer(osm); map.setView(new L.LatLng(lat, lng), zoom); var popup = L.popup() .setContent('<p>Hello world!<br />This is a nice popup.</p>') .on('click', onClick); L.marker([51, 0]).bindPopup(popup).addTo(map).on('click', onClick); L.marker([51, 1.5]).bindPopup(popup).addTo(map).on('click', onClick); function onClick(event) { event.target.closePopup(); } } </script> </head> <body> <div id="map"></div> <table id="properties"></table> <button id="openStuff">Open Stuff</button> </body> </html>