AnsweredAssumed Answered

Adding click and zoom functionality

Question asked by joepub on Sep 26, 2015
Latest reply on Sep 30, 2015 by joepub

I have the following app (ICGC WEB PORTAL)  Based on which button at the top clicked on, certain countries are highlighted, I  need help with the following:

 

I want to pan to(?)/center on the country clicked on as well as increase the zoom level.

This is my attempt

 

function getExtent(){

  var lat = map.getCenter().lat;

  var lng = map.getCenter().lng;

  var newCord = [lat, lng];

  return newCord;

}

 

function highlightFeature(e){

   var newCenter = getExtent();  <--

   var layer = e.target

  [stuff omitted]

}

 

function onEachFeature(feature, layer){

  layer.on({

    click: highlightFeature

  });

}

 

countries = L.geoJson(featureCollection, {

   onEachFeature: onEachFeature

}).addTo(map);

 

 

Script attached

Attachments

Outcomes