Permalink
Browse files

got the marker resize to work on zoom out

  • Loading branch information...
1 parent 8d10e06 commit c6a91da3bcf7ad7d15498db924e56b86989c058e @SpencerCooley committed Apr 9, 2012
Showing with 44 additions and 2 deletions.
  1. +22 −1 js/script.js
  2. +22 −1 js/script.js~
  3. BIN marker.png
View
@@ -27,6 +27,20 @@ map.addLayer(polygon);
map.on('click', function(e) {
+
+ //this sets up an icon to be replaced when redraw.
+ var MyIcon = L.Icon.extend({
+ iconUrl: 'marker.png',
+ iconSize: new L.Point(10, 16),
+ shadowSize: new L.Point(10, 16),
+ iconAnchor: new L.Point(10, 16)
+ });
+
+ var icon = new MyIcon();
+ //this sets up an icon to be replaced when redraw.
+
+
+
var marker = new L.Marker(e.latlng, {draggable:true});
polygonPoints.push(e.latlng);
var markerId = polygonPoints.length -1
@@ -42,7 +56,14 @@ map.on('click', function(e) {
polygon.setLatLngs(polygonPoints);
});
-
+
+ //When view resets use the small icon if zoom level is less than 13
+ map.on('viewreset', function(){
+ if(map.getZoom() < 13){
+
+ marker.setIcon(icon);
+ }
+ });
});
View
@@ -27,6 +27,20 @@ map.addLayer(polygon);
map.on('click', function(e) {
+
+ //this sets up an icon to be replaced when redraw.
+ var MyIcon = L.Icon.extend({
+ iconUrl: 'marker.png',
+ iconSize: new L.Point(10, 16),
+ shadowSize: new L.Point(10, 16),
+ iconAnchor: new L.Point(10, 16)
+ });
+
+ var icon = new MyIcon();
+ //this sets up an icon to be replaced when redraw.
+
+
+
var marker = new L.Marker(e.latlng, {draggable:true});
polygonPoints.push(e.latlng);
var markerId = polygonPoints.length -1
@@ -42,7 +56,14 @@ map.on('click', function(e) {
polygon.setLatLngs(polygonPoints);
});
-
+
+ //When view resets use the small icon if zoom level is less than 13
+ map.on('viewreset', function(){
+ if(map.getZoom() < 13){
+
+ marker.setIcon(icon);
+ }
+ });
});
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c6a91da

Please sign in to comment.