Permalink
Browse files

Markers grouping. Added $.noop to Zepto adapter.

  • Loading branch information...
mmarcon committed Dec 7, 2012
1 parent 1f934a9 commit 761be3e5d2556b7323a9a0c49197ce3c7a0cf6f4

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -12,12 +12,43 @@
right: 0;
background: white;
}
ul {
position: absolute;
bottom: 0;
left: 0;
right: 0;
margin: 0;
padding: 0;
background: #222;
height: 80px;
}
li {
display: inline-block;
font-family: 'American Typewriter', sans-serif;
font-weight: 100;
font-size: 24px;
padding: 28px 10px;
line-height: 1;
cursor: pointer;
color: #fff;
border-right: 1px dotted #666;
}
li:hover, li.active {
color: #4169e1;
}
</style>
</head>
<body>
<div id="map"></div>
<div class="route"></div>
<ul class="toolbar">
<li data-group="restaurants">
Restaurants
</li>
</ul>
<!-- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script> -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/zepto/1.0rc1/zepto.min.js"></script>
<script type="text/javascript" src="../zepto.adapter.js"></script>
@@ -27,9 +58,18 @@
$(window).on('load', function(){
$('#map').jHERE({
center: [52.5, 13.3],
zoom: 10
}).jHERE('marker', [52.5, 13.3], function(marker){
marker.on('click', function(){alert('banana'); this.remove();});
zoom: 12
})
.jHERE('marker', [52.5, 13.3], {group: 'restaurants', fill: '#4169e1'})
.jHERE('marker', [52.5, 13.35], {group: 'restaurants', fill: '#4169e1'})
.jHERE('marker', [52.52, 13.3], {group: 'restaurants', fill: '#4169e1'})
.jHERE('marker', [52.51, 13.27], {group: 'restaurants', fill: '#4169e1'})
.jHERE('marker', [52.52, 13.34], {group: 'restaurants', fill: '#4169e1'})
.jHERE('marker', [52.48, 13.4], {group: 'restaurants', fill: '#4169e1'});
$('li').on('click', function(){
$(this).toggleClass('active');
$.jHERE.getMarkersGroup($(this).data('group')).toggle();
});
});
</script>
@@ -8,7 +8,6 @@ without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
@@ -69,16 +68,25 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
G.hide = function(){
if(this.visible) {
this.map.objects.remove(this.container);
this.visible = false;
}
};
G.show = function(){
if(!this.visible) {
this.map.objects.show(this.container);
this.map.objects.add(this.container);
this.visible = true;
}
};
G.toggle = function(){
if(this.visible) {
return this.hide();
}
this.show();
};
jHEREMarkerGroup.getGroup = function(group){
$.jHERE.getMarkersGroup = function(group){
group = group || UNGROUPED;
return groups[group];
};
@@ -134,11 +142,11 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
};
M.remove = function(){
groups[this.group].objects.remove(this.marker);
groups[this.group.name].container.objects.remove(this.marker);
};
M.add = function(){
groups[this.group].objects.add(this.marker);
groups[this.group.name].container.objects.add(this.marker);
};
/*
@@ -166,6 +174,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
closure = markerOptions;
markerOptions = {};
}
closure = closure || $.noop;
markerOptions = $.extend({}, _default.marker, markerOptions);
/*Normalize settings*/
@@ -175,10 +184,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*Create group if not existing already*/
if(!groups[markerOptions.group]){
groups[markerOptions.group] = new jHEREMarkerGroup(_ns.map.Container(), markerOptions.group, this.map);
groups[markerOptions.group] = new jHEREMarkerGroup(new _ns.map.Container(), markerOptions.group, this.map);
this.map.objects.add(groups[markerOptions.group].container);
markerOptions.group = groups[markerOptions.group];
}
markerOptions.group = groups[markerOptions.group];
if (markerOptions.icon) {
marker = new jHEREMarker(new _ns.map.Marker(position, markerOptions), markerOptions);
@@ -187,7 +196,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
marker.add();
closure.call(this.element, marker);
closure.call(this.element, marker, marker.group);
};
function isFunction(fn) {
View
@@ -24,6 +24,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
$.error = function(msg){
throw new Error(msg);
};
$.noop = function(){};
/*MINIMAL implementation of $.Deferred*/
/*This only implements the method required by jHERE*/
/*So do not use it for real "promises" purpose*/

0 comments on commit 761be3e

Please sign in to comment.