forked from ubergesundheit/Leaflet.EdgeMarker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.1.0 - Initial modified fork release
- Loading branch information
Ray Walker
committed
Mar 25, 2014
1 parent
d164398
commit 8c33151
Showing
8 changed files
with
260 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module.exports = function(grunt) { | ||
|
||
// Project configuration. | ||
grunt.initConfig({ | ||
pkg: grunt.file.readJSON('package.json'), | ||
jshint: {// https://www.npmjs.org/package/grunt-contrib-jshint | ||
options: { | ||
curly: true, | ||
eqeqeq: true, | ||
eqnull: true, | ||
browser: true, | ||
globals: { | ||
jQuery: true, | ||
L: true, | ||
console: true | ||
} | ||
}, | ||
files: 'leaflet.edgeMarker-raywalker.js' | ||
}, | ||
uglify: { | ||
options: { | ||
banner: '/** <%= pkg.name %> - <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> - <%= pkg.license %> License - <%= pkg.homepage %> */\n' | ||
}, | ||
build: { | ||
src: 'leaflet.edgeMarker-raywalker.js', | ||
dest: 'leaflet.edgeMarker-raywalker.min.js' | ||
} | ||
}, | ||
watch: { | ||
options: { | ||
spawn: false, | ||
reporter: require('jshint-stylish') | ||
}, | ||
target: { | ||
files: 'leaflet.edgeMarker-raywalker.js', | ||
tasks: ['javascript'] | ||
|
||
} | ||
} | ||
}); | ||
|
||
// Javascript code quality assurance | ||
grunt.loadNpmTasks('grunt-contrib-jshint'); | ||
|
||
// Load the plugin that provides the "uglify" task. | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
|
||
// Javascript code quality assurance | ||
grunt.loadNpmTasks('grunt-contrib-watch'); | ||
|
||
// Default task(s). | ||
grunt.registerTask('default', ['jshint', 'uglify']); | ||
|
||
grunt.registerTask('javascript', ['jshint', 'uglify']); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
Leaflet EdgeMarker | ||
================== | ||
Leaflet EdgeMarker for Greenpeace Mapping | ||
========================================= | ||
|
||
Leaflet EdgeMarker is a [Leaflet](http://leafletjs.com/) plugin which allows you to indicate Markers, Circles and CircleMarkers that are outside of the current view by displaying CircleMarkers at the edges of the map. | ||
Leaflet EdgeMarker is a [Leaflet](http://leafletjs.com/) plugin which allows you to indicate Markers, | ||
Circles and CircleMarkers that are outside of the current view by displaying CircleMarkers at the edges of the map. | ||
|
||
Demo | ||
---- | ||
|
||
Check out the [demo](http://ubergesundheit.github.io/Leaflet.EdgeMarker) | ||
|
||
Usage | ||
----- | ||
|
||
* Download the `Leaflet.EdgeMarker.js` | ||
* Include the file after you included `leaflet.js` | ||
* Initialize the EdgeMarkers with `L.edgeMarker().addTo(map)` **after** you initialized your `map` and Markers/Circles/CircleMarkers | ||
|
||
**Or look at the source of `example.html`** | ||
This fork of Gerald Pape's original plugin was created to add | ||
* transitions on map move | ||
* superimposed icons on the edge markers | ||
* installation via Bower | ||
* building via Grunt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/** | ||
* | ||
* @version | ||
* @source https://github.com/funkygibbing/Leaflet.EdgeMarker | ||
* @param {type} L | ||
* @returns {undefined} | ||
*/ | ||
(function(L, $) { | ||
'use strict'; | ||
|
||
L.EdgeMarker = L.Class.extend({ | ||
options: { | ||
radius: 30, | ||
weight: 1, | ||
color: 'white', | ||
fillColor: 'white', | ||
fillOpacity: 1, | ||
className: 'edgeMarker', | ||
transitionClass: 'quickFadeOut' | ||
}, | ||
timer: false, | ||
delay: 100, | ||
initialize: function(options) { | ||
L.setOptions(this, options); | ||
}, | ||
addTo: function(map) { | ||
var timer = false; | ||
this._map = map; | ||
|
||
//add a method to get applicable features | ||
L.extend(map, { | ||
_getFeatures: function() { | ||
var out = []; | ||
for (var l in this._layers) { | ||
if (typeof this._layers[l].getLatLng !== 'undefined') { | ||
out.push(this._layers[l]); | ||
} | ||
} | ||
return out; | ||
} | ||
}); | ||
|
||
map.on('move', function() { | ||
var that = this; | ||
|
||
if (typeof this._borderMarkerLayer !== 'undefined') { | ||
$('.' + this.options.className).addClass(this.options.transitionClass); | ||
} | ||
|
||
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
|
||
timer = setTimeout(function() { | ||
that._addEdgeMarkers(); | ||
}, that.delay); | ||
|
||
}, this); | ||
|
||
map.on('viewreset', function() { | ||
var that = this; | ||
|
||
if (typeof this._borderMarkerLayer !== 'undefined') { | ||
this._borderMarkerLayer.clearLayers(); | ||
} | ||
|
||
if (timer) { | ||
clearTimeout(timer); | ||
} | ||
|
||
timer = setTimeout(function() { | ||
that._addEdgeMarkers(); | ||
}, that.delay); | ||
}, this); | ||
|
||
this._addEdgeMarkers(); | ||
|
||
map.addLayer(this); | ||
|
||
return this; | ||
}, | ||
onAdd: function() { | ||
}, | ||
_borderMarkerLayer: false, | ||
_addEdgeMarkers: function() { | ||
if (!this._borderMarkerLayer) { | ||
this._borderMarkerLayer = new L.LayerGroup(); | ||
} | ||
this._borderMarkerLayer.clearLayers(); | ||
|
||
var features = this._map._getFeatures(), | ||
markerDiv = false, | ||
markerIcon = false, | ||
that = this; | ||
|
||
$.each(features, function(i, feature) { | ||
var f = feature.feature; | ||
|
||
if (typeof f.properties.edgeMarker !== "undefined") { | ||
|
||
var icon = $.extend(true, {className: that.options.className}, f.properties.edgeMarker), | ||
latlng = feature.getLatLng(), | ||
currentMarkerPosition = that._map.latLngToContainerPoint(latlng), | ||
mapPixelBounds = that._map.getSize(); | ||
|
||
if (currentMarkerPosition.y < 0 || | ||
currentMarkerPosition.y > mapPixelBounds.y || | ||
currentMarkerPosition.x > mapPixelBounds.x || | ||
currentMarkerPosition.x < 0) { | ||
|
||
var y = currentMarkerPosition.y, | ||
x = currentMarkerPosition.x, | ||
x_offset = icon.iconSize[0] / 2.2, | ||
y_offset = icon.iconSize[1] / 2.2; | ||
|
||
if (currentMarkerPosition.y < 0) { | ||
y = 0; | ||
icon.iconAnchor[1] = icon.iconAnchor[1] - y_offset; | ||
} else if (currentMarkerPosition.y > mapPixelBounds.y) { | ||
y = mapPixelBounds.y; | ||
icon.iconAnchor[1] = icon.iconAnchor[1] + y_offset; | ||
} | ||
|
||
if (currentMarkerPosition.x > mapPixelBounds.x) { | ||
x = mapPixelBounds.x; | ||
icon.iconAnchor[0] = icon.iconAnchor[0] + x_offset; | ||
} else if (currentMarkerPosition.x < 0) { | ||
x = 0; | ||
icon.iconAnchor[0] = icon.iconAnchor[0] - x_offset; | ||
} | ||
|
||
if (typeof f.properties.icon === 'object') { | ||
markerDiv = L.marker(that._map.containerPointToLatLng([x, y]), {icon: L.divIcon({className: that.options.className + ' edgeMarkerCircle', | ||
iconSize: [that.options.radius * 2, that.options.radius * 2]})}).addTo(that._borderMarkerLayer); | ||
|
||
markerIcon = L.marker(that._map.containerPointToLatLng([x, y]), {icon: L.icon(icon)}) | ||
.addTo(that._borderMarkerLayer); | ||
|
||
} else { | ||
markerIcon = L.circleMarker(that._map.containerPointToLatLng([x, y]), that.options) | ||
.addTo(that._borderMarkerLayer); | ||
} | ||
|
||
markerIcon.on('click', function(e) { | ||
that._map.panTo(latlng, {animate: true}); | ||
}); | ||
|
||
if (markerDiv) { | ||
markerDiv.on('click', function() { | ||
that._map.panTo(latlng, {animate: true}); | ||
}); | ||
} | ||
|
||
} | ||
} | ||
|
||
}); | ||
if (!this._map.hasLayer(this._borderMarkerLayer)) { | ||
this._borderMarkerLayer.addTo(this._map); | ||
} | ||
} | ||
}); | ||
|
||
L.edgeMarker = function(options) { | ||
return new L.EdgeMarker(options); | ||
}; | ||
|
||
}(L, jQuery)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "Leaflet.EdgeMarker-raywalker", | ||
"version": "0.1.0", | ||
"description": "Leaflet EdgeMarker is a [Leaflet](http://leafletjs.com/) plugin which allows you to indicate Markers, Circles and CircleMarkers that are outside of the current view by displaying CircleMarkers at the edges of the map. Modified for use in Greenpace Mapping projects.", | ||
"main": "leaflet.edgeMarker-raywalker.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/raywalker-it/Leaflet.EdgeMarker-raywalker" | ||
}, | ||
"authors": "Ray Walker <[email protected]>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/raywalker-it/Leaflet.EdgeMarker-raywalker/issues" | ||
}, | ||
"homepage": "https://github.com/raywalker-it/Leaflet.EdgeMarker-raywalker", | ||
"devDependencies": { | ||
"grunt": "^0.4.4", | ||
"grunt-contrib-uglify": "^0.4.0", | ||
"grunt-contrib-jshint": "^0.9.2", | ||
"jshint-stylish": "^0.1.5", | ||
"grunt-contrib-watch": "^0.6.1" | ||
} | ||
} |