-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Size spec added and new template added using BlurredLocation object #7
Changes from 12 commits
f6921cb
d7696ad
d7a4617
b78d5ea
c29e827
138b289
d05e6ef
ab651be
f70fc71
42c8f43
0124158
b7b9ac7
1a486dc
b62fa04
51d742c
4c0c13a
32cb2fb
363190f
8bfa37c
0af7deb
655845e
f1d554e
81efadc
e345dca
0c49afb
54cb90e
1bbab6b
c289926
f5fd39a
9b3507f
d51c63c
642ab51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is ok but by using |
||
<html lang="en"> | ||
<head> | ||
|
||
<title>Leaflet.BlurredLocation</title> | ||
</head> | ||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | ||
<link href="../node_modules/leaflet/dist/leaflet.css" rel="stylesheet"> | ||
<body> | ||
<!-- START OF EXAMPLE --> | ||
<div class="container" > | ||
<div class="row" > | ||
<div class="col-md-8"> | ||
<label class="h2 font-size-big"><input type="radio" /> Add location to your content</label> | ||
<br/><br/> | ||
<h4 class="font-size-small">Option 1 : By Placename</h4> | ||
</br> | ||
<input id="geo_location" type="text" class="form-control"><br/> | ||
<h4 class="font-size-small">Option 2 : By dragging the map</h4></br> | ||
<h4 class="font-size-small">Option 3 : By giving co-ordinates</h4></br> | ||
<div class="col-md-6"> | ||
<input id="lat" type="text" class="form-control" placeholder="Latitude"><br/> | ||
</div> | ||
<div class="col-md-6"> | ||
<input id="lng" type="text" class="form-control" placeholder="Longitude"><br/> | ||
</div> | ||
<label class="h2 font-size-big"><input type="checkbox" onchange='getLocation(this);'> Obscure my exact location</label> | ||
</div> | ||
<div class="col-md-4"> | ||
<h3 class="font-size-small">On a map : </h3> | ||
<br /> | ||
<div id="map" class="leaflet-map" style="width: 400px; height: 400px;"></div> | ||
<br/> | ||
<h3 class="font-size-small">In Text:</h3><br/> | ||
<input id="location" type="text" class="form-control"><br/> | ||
</div> | ||
</div> | ||
</div> | ||
<!-- END OF EXAMPLE --> | ||
</body> | ||
<script src="../dist/built.js"></script> | ||
|
||
|
||
<script> | ||
var blurredLocation = new BlurredLocation({ | ||
lat: 41.01, | ||
lon: -85.66 | ||
}); | ||
</script> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,35 @@ | ||
function BlurredLocation(location) { | ||
if(map) { | ||
map.setView([location.lat, location.lon], 10); | ||
this.getLat = function () { | ||
return map.getCenter().lat; | ||
} | ||
this.getLon = function() { | ||
return map.getCenter().lng; | ||
} | ||
this.goTo = function(lat, lon, zoom) { | ||
map.setView([lat, lon], zoom); | ||
} | ||
this.geocode = function(string) { | ||
$.ajaxSetup({async: false}); | ||
var url = "https://maps.googleapis.com/maps/api/geocode/json?address="+string.split(" ").join("+"); | ||
var temp = $.ajax({ | ||
async: false, | ||
url: url | ||
}); | ||
var geometry = temp.responseJSON.results[0].geometry.location; | ||
var default_zoom = 13; | ||
console.log(geometry.lat); | ||
map.setView([geometry.lat, geometry.lng],default_zoom); | ||
return geometry; | ||
} | ||
if(!map) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is great, but lets set function BlurredLocation(options) {
options = options || {};
options.map = options.map || L.map('map');
options.location = options.location || someDefault;
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that looks neat. |
||
var map = L.map('map'); | ||
L.tileLayer("https://a.tiles.mapbox.com/v3/jywarren.map-lmrwb2em/{z}/{x}/{y}.png").addTo(map); | ||
} | ||
} | ||
map.setView([location.lat, location.lon], 10); | ||
this.getLat = function () { | ||
return map.getCenter().lat; | ||
} | ||
this.getLon = function() { | ||
return map.getCenter().lng; | ||
} | ||
this.goTo = function(lat, lon, zoom) { | ||
map.setView([lat, lon], zoom); | ||
} | ||
this.geocode = function(string) { | ||
var url = "https://maps.googleapis.com/maps/api/geocode/json?address="+string.split(" ").join("+"); | ||
var Blurred = $.ajax({ | ||
async: false, | ||
url: url | ||
}); | ||
// console.log(Object.getOwnPropertyNames(Blurred)); | ||
// console.log(Blurred.readyState); | ||
|
||
var geometry = Blurred.responseJSON.results[0].geometry.location; | ||
var default_zoom = 13; | ||
// console.log(geometry.lat); | ||
map.setView([geometry.lat, geometry.lng],default_zoom); | ||
return geometry; | ||
} | ||
this.getSize = function() { | ||
return map.getSize(); | ||
} | ||
} | ||
exports.BlurredLocation = BlurredLocation; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then concat also seems redundant with Browserify and uglify - which are we using to compile? It looks liek concat, based on line 76, but maybe we should be using Browserify, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at the Browserify example in PublicLab.Editor -- it'll be helpful! or in https://github.com/publiclab/inline-markdown-editor/blob/master/Gruntfile.js#L55 -- a bit simpler!