Permalink
Browse files

Merge branch 'master' of github.com:mmarcon/jhere

  • Loading branch information...
2 parents 568c1b1 + c7a08d3 commit caff3c9e43c393fe720e3be5bcb316223fa88a2a @mmarcon committed Nov 14, 2013
Showing with 27 additions and 2 deletions.
  1. +17 −0 src/examples/example.shapes.html
  2. +10 −2 src/extensions/shapes.js
@@ -12,10 +12,24 @@
right: 0;
background: white;
}
+
+ .clearbutton {
+ position: absolute;
+ top: 5px;
+ left: 5px;
+ background: #222;
+ color: #fff;
+ z-index: 1000;
+ font-family: 'Helvetica', sans-serif;
+ padding: 10px;
+ border-radius: 3px;
+ cursor: pointer;
+ }
</style>
</head>
<body>
+<div class="clearbutton">Clear all shapes</div>
<div id="map"></div>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto.min.js"></script>
@@ -48,6 +62,9 @@
thickness: 1,
stroke: '#111'
}});
+ $('.clearbutton').on('click', function(){
+ map.jHERE('clearShapes');
+ });
});
</script>
</body>
View
@@ -21,7 +21,7 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
;(function($){
- var _ns, shape, circle, rectangle, polyline, polygon, shapeContainer;
+ var _ns, shape, clearShapes, circle, rectangle, polyline, polygon, shapeContainer;
function normalize(position){
return position instanceof Array ? {latitude: position[0], longitude: position[1]} : position;
@@ -113,6 +113,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
$.error(shape + ' not supported');
}
};
+
+ //###Clear all shapes from the map
+ clearShapes = function() {
+ if (shapeContainer && shapeContainer.objects) {
+ shapeContainer.objects.clear();
+ }
+ };
circle = function(options){
shape.call(this, 'circle', options);
@@ -131,8 +138,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
};
$.jHERE.extend('shape', shape);
+ $.jHERE.extend('clearShapes', clearShapes);
$.jHERE.extend('circle', circle);
$.jHERE.extend('rectangle', rectangle);
$.jHERE.extend('polyline', polyline);
$.jHERE.extend('polygon', polygon);
-}(jQuery));
+}(jQuery));

0 comments on commit caff3c9

Please sign in to comment.