Skip to content

Instantly share code, notes, and snippets.

@allthesignals
Created August 19, 2016 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allthesignals/c2bd2f59649c846a5fb55f5f7cad5c65 to your computer and use it in GitHub Desktop.
Save allthesignals/c2bd2f59649c846a5fb55f5f7cad5c65 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
minLat: 42.257645,
minLng: -71.808530,
maxLat: 42.265083,
maxLng: -71.794659,
bounds: function() {
var minLat = parseFloat(this.get('minLat').toFixed(6));
var minLng = parseFloat(this.get('minLng').toFixed(6));
var maxLat = parseFloat(this.get('maxLat').toFixed(6));
var maxLng = parseFloat(this.get('maxLng').toFixed(6));
return L.latLngBounds([[minLat, minLng],
[maxLat, maxLng]]);
}.property('minLat,minLng,maxLat,maxLng'),
actions: {
updateMax(r,e) {
var location = e.target.getLatLng();
this.set('maxLat', location.lat);
this.set('maxLng', location.lng);
},
updateMin(r,e) {
var location = e.target.getLatLng();
this.set('minLat', location.lat);
this.set('minLng', location.lng);
}
}
});
html, body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
height: 100%;
width: 100%;
}
.leaflet-container {
height: 600px;
}
{{#leaflet-map bounds=bounds}}
{{tile-layer url="http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"}}
{{marker-layer lat=minLat lng=minLng draggable=true onDragend=(action "updateMin" r)}}
{{marker-layer lat=maxLat lng=maxLng draggable=true onDragend=(action "updateMax" r)}}
{{/leaflet-map}}
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0",
"leaflet": "~0.7.7"
},
"addons": {
"ember-leaflet": "2.2.7"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment