Skip to content

Instantly share code, notes, and snippets.

@adriatic
Last active July 19, 2016 18:49
Show Gist options
  • Save adriatic/51da5a17a99bd869725a908d2f4134d2 to your computer and use it in GitHub Desktop.
Save adriatic/51da5a17a99bd869725a908d2f4134d2 to your computer and use it in GitHub Desktop.
Map: bubble layer
<template>
<div id="example">
<div class="box wide">
<div class="box-col">
<h4>Bubble symbol</h4>
<ul ref="selectSymbol">
<li>Circle</li>
<li>Square</li>
</ul>
</div>
<div ref="info" class="box-col"></div>
</div>
<div id="map-bubble-layer">
<div style="text-align: center">
<ak-map k-center.bind = "center"
k-zoom.bind = "4"
k-min-zoom.bind = "3"
k-wraparound.bind = "false"
k-layers.bind = "layers"
k-widget.two-way = "map"
k-on-shape-mouse-enter.delegate="onShapeMouseEnter($event.detail)"
k-on-reset.delegate="onReset()">
</ak-map>
</div>
</div>
</div>
<script ref="infoTemplate" type="text/x-kendo-template">
<h4>#: City #, #= Country #</h4>
<p class="info">Population #= kendo.toString(Pop2010 * 1000, "N0") #</p>
</script>
<script ref="emptyInfoTemplate" type="text/x-kendo-template">
<h4>Hover over urban areas</h4>
<p>&nbsp;</p>
</script>
</template>
import 'kendo-ui/js/kendo.mobile.buttongroup.min';
export class BubbleLayer {
center = [45, 45];
layers = [{
type: 'tile',
urlTemplate: 'http://otile3.mqcdn.com/tiles/1.0.0/sat/#= zoom #/#= x #/#= y #.png',
attribution: 'Tiles &copy; <a href=\'http://www.mapquest.com/\' target=\'_blank\'>MapQuest</a>'
}, {
type: 'bubble',
attribution: 'Population data from Nordpil and UN Population Division.',
style: {
fill: {
color: '#fff',
opacity: 0.4
},
stroke: {
width: 0
}
},
dataSource: new kendo.data.DataSource({
transport: {
read: function(options) {
return System.import('samples/map/json/urban-areas.json!json')
.then(data => options.success(data));
}
}
}),
locationField: 'Location',
valueField: 'Pop2010'
}];
attached() {
$(this.selectSymbol).kendoMobileButtonGroup({
select: (e) => {
let layer = this.map.layers[1];
layer.options.symbol = e.index === 0 ? 'circle' : 'square';
layer.reset();
},
index: 0
});
}
onReset() {
this.info.innerHTML = kendo.template(this.emptyInfoTemplate.innerHTML)({});
this.activeShape = null;
}
onShapeMouseEnter(e) {
if (this.activeShape) {
this.activeShape.options.set('stroke', null);
}
this.activeShape = e.shape;
this.activeShape.options.set('stroke', { width: 1.5, color: '#fff' });
this.info.innerHTML = kendo.template(this.infoTemplate.innerHTML)(e.shape.dataItem);
}
}
<!doctype html>
<html>
<head>
<title>Aurelia KendoUI bridge</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.common.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.rtl.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.default.min.css">
<link rel="stylesheet" href="https://kendo.cdn.telerik.com/2016.1.226/styles/kendo.mobile.all.min.css">
<script src="https://kendo.cdn.telerik.com/2016.1.226/js/jszip.min.js"></script>
</head>
<body aurelia-app="main">
<h1>Loading...</h1>
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.6/system.js"></script>
<script src="https://rawgit.com/aurelia-ui-toolkits/aurelia-kendoui-bundles/0.3.5/config2.js"></script>
<script>
System.import('aurelia-bootstrapper');
</script>
</body>
</html>
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-kendoui-bridge', kendo => kendo.pro());
aurelia.start().then(a => a.setRoot());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment