Witam!

mam mały problem, mianowicie przerobiłem lekko kod mapboxa, który miał zmieniać kolor danego utworzonego kształtu gdy znajdzie się w nim marker.
skrypt działa, lecz zmienia kolor wszystkich kształtów a miałby robić to tylko dla tego w którym jest marker.
prosiłbym o pomoc jak to wykonać. ponizej cały kod:

  1. <!DOCTYPE html>
  2. <meta charset=utf-8 />
  3. <title>Point in Polygon</title>
  4.  
  5. <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
  6. <script src='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.js'></script>
  7. <link href='https://api.tiles.mapbox.com/mapbox.js/v1.6.2/mapbox.css' rel='stylesheet' />
  8.  
  9. body { margin:0; padding:0; }
  10. #map { position:absolute; top:0; bottom:0; width:100%; }
  11. </head>
  12. #state {
  13. position:absolute;
  14. top:10px;
  15. right:10px;
  16. background:#fff;
  17. font-size:30px;
  18. padding:10px;
  19. z-index:999;
  20. }
  21.  
  22. <script src='js/leaflet-pip.js'></script>
  23. <div id='map'></div>
  24. <div id='state'></div>
  25. var map = L.mapbox.map('map', 'examples.map-9ijuk24y')
  26. .setView([60, -102.0], 5);
  27.  
  28.  
  29.  
  30. var geoobj = [{
  31. "type":"Polygon",
  32. "properties": { "e": "1" },
  33. "coordinates":[[[100,20],[129.5,10.5],[130.5,21],[110,20]]]
  34. },
  35. {
  36. "type":"Polygon",
  37. "properties": { "e": "2" },
  38. "coordinates":[[[30,40],[11.5,4.5],[-31.5,41],[10,30]]]
  39. }
  40. ];
  41.  
  42.  
  43. var states = L.geoJson(geoobj, {color: "#ff7800", weight: 1}).addTo(map);
  44. L.marker([10, 122], {
  45. icon: L.mapbox.marker.icon({
  46. 'marker-color': '#f22'
  47. }),
  48. draggable: true
  49. }).addTo(map)
  50. .on('dragend', function(e) {
  51. var layer = leafletPip.pointInLayer(this.getLatLng(), states, true);
  52.  
  53. // document.getElementById('state').innerHTML = 'cos tam2' ?
  54. // layer[0].feature.properties.name : 'cos tam';
  55.  
  56. var layer = leafletPip.pointInLayer(this.getLatLng(), states, true);
  57. states.setStyle({fillColor: 'black'});
  58.  
  59. if(layer == false) {
  60. states.setStyle({fillColor: '#ff7800'});
  61. }
  62.  
  63. });
  64.  
  65.  
  66. </body>
  67. </html>


poniżej link do skryptu:
http://jsfiddle.net/k4fzn/1/