Skip to content

Added ILayer events to Layer.js #31

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions debug/lvector-ilayer-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.5/leaflet.css" />

<script src="http://cdn.leafletjs.com/leaflet-0.5/leaflet.js"></script>

<script src="../src/lvector.js"></script>
<script src="../src/core/Util.js"></script>
<script src="../src/core/Class.js"></script>
<script src="../src/layer/Layer.js"></script>
<script src="../src/layer/GeoJSONLayer.js"></script>
<script src="../src/layer/EsriJSONLayer.js"></script>
<script src="../src/layer/AGS.js"></script>
<script src="../src/layer/GISCloud.js"></script>
<script src="../src/layer/PRWSF.js"></script>

<style type="text/css">
#map {
height: 400px;
width: 100%;
}
</style>
</head>
<body>
<div id="map">
</div>

<p>
To see example, toggle the endangered species critical habitat layer on and off.
</p>

<script type="text/javascript">
var arcgisServerStreetsUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}.png"
var arcgisServerWorldImageryUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}.png"
var arcgisServerTopoUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}.png"
var arcgisSoilSurveyUrl = "http://server.arcgisonline.com/ArcGIS/rest/services/Specialty/Soil_Survey_Map/MapServer/tile/{z}/{y}/{x}.png"

var baseMaps = {
"Streets":L.tileLayer(arcgisServerStreetsUrl, {attribution:"Source: Esri"}),
"Imagery":L.tileLayer(arcgisServerWorldImageryUrl, {attribution:"Source: Esri, DigitalGlobe, GeoEye, i-cubed, USDA, USGS, AEX, Getmapping, Aerogrid, IGN, IGP, and the GIS User Community"}),
"Topographic":L.tileLayer(arcgisServerTopoUrl, {attribution:"Source: Esri"}),
"Soils":L.tileLayer(arcgisSoilSurveyUrl, {attribution:"Source: Esri"})
}

var serviceUrl = "http://ecos.fws.gov/rest/services/crithab/crithabMapper/MapServer"
var overlays = {
"Endangered Species Critical Habitat": new L.LayerGroup([
new lvector.AGS({
url: serviceUrl + "/6",
fields: "objectid, entity_id",
scaleRange: [1, 11],
uniqueField: "objectid",
showAll: false,
singlePopup: true
}),
new lvector.AGS({
url: serviceUrl + "/7",
fields: "objectid, entity_id",
scaleRange: [12, 24],
uniqueField: "objectid",
singlePopup: true
})
])
}
var config = {
center: new L.LatLng(40.5, -105),
zoom: 10,
layers: [baseMaps.Streets]
}


window.map = L.map('map', config)

var layersControl = L.control.layers(baseMaps, overlays)
layersControl.addTo(window.map)
</script>
</body>
9 changes: 9 additions & 0 deletions src/layer/Layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ lvector.Layer = lvector.Class.extend({
getMap: function() {
return this.options.map;
},

onAdd: function(map) {
this.setMap(map)
},

onRemove: function(map) {
if (map == this.options.map)
this.setMap(null)
},

setOptions: function(o) {
// TODO - Merge new options (o) with current options (this.options)
Expand Down