3

Hi I have a series of circles using mapquest and leaflet

The circle data is dynamically generated from querying the sql table that contacts: circle name, long / lat center position and radius.

I want the user to be able to click on any of the circles and the click event load the edit circle page that then loads another map page that only shows the single circle that was clicked on for editing rather than the collection of circles.

Loading the specific circle edit page etc is all sorted what i need to understand is what the syntax needed so i can click a circle and that loads the page editcircle.html?circleid=4

RPichioli
  • 3,245
  • 2
  • 25
  • 29

1 Answers1

0

You can use the window.open method in a marker.on('click') event, as follows:

var marker = L.marker(L.latLng(p.lat, p.lon));
   marker.on('click', function() {
        //remove all markers
        map.removeLayer(markers);
      marker.addTo(map);
        //open your edit page here
        window.open(base_url + p.id);
   });
   markers.addLayer(marker);

I created a JSfiddle to show you what it does (https://jsfiddle.net/vaillant/yedg0hsd/). You used circles rather than marker, but that would be exactly the same procedure. I hope it helps.

Philippe V.
  • 508
  • 3
  • 10