sjy-ecos/public/js/mod.js

109 lines
2.5 KiB
JavaScript
Raw Normal View History

2016-12-24 18:53:44 +00:00
$('.navbar-nav li a').each(function () {
if ($($(this))[0].href == String(window.location)) {
$(this).parent().addClass('active');
}
else if (window.location.pathname == '/') {
$('.navbar-nav li').first().addClass('active');
}
else {
$('.navbar-nav li').first().removeClass('active');
}
});
2017-02-07 07:05:05 +00:00
function onEachFeature(feature, layer) {
var out = [];
if (feature.properties) {
for (var key in feature.properties) {
out.push(key + ": " + feature.properties[key]);
}
}
layer.bindPopup(out.join("<br />"));
}
2016-12-24 18:53:44 +00:00
// $(document).on('click', '.navbar-nav li', function () {
// $(".nav-list li").removeClass("active");
// $(this).addClass("active");
// });
2017-02-07 09:49:34 +00:00
2017-02-12 13:26:00 +00:00
function loadStaticMap() {
var base_map = L.tileLayer('http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
maxZoom: 18
});
var over_geojson_sjy_bound_2nd = new L.GeoJSON.AJAX("/json/sjy_bound_2nd.geojson", {
style: {
"color": "#de950d",
"weight": 2,
"opacity": 1,
"fillOpacity": 0
}
});
var map = L.map('map', {
layers: [
base_map,
over_geojson_sjy_bound_2nd
],
minZoom: 6,
maxZoom: 17,
zoomIn: 1,
zoomOut: 1,
zoomControl: false
}).setView([34, 96], 6);
var bounds = new L.LatLngBounds(new L.LatLng(31, 103), new L.LatLng(38, 89));
map.fitBounds(bounds);
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
map.invalidateSize();
});
}
2017-02-07 09:49:34 +00:00
function loadStationMap(station) {
var base_map = L.tileLayer('http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
maxZoom: 18
});
var over_geojson_sjy_bound_2nd = new L.GeoJSON.AJAX("/json/sjy_bound_2nd.geojson", {
style: {
"color": "#de950d",
"weight": 2,
"opacity": 1,
"fillOpacity": 0
}
});
var over_geojson_station = new L.GeoJSON.AJAX("/api/gis/geojson/" + station, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
radius: 4,
fillColor: "#0aff3c",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8
})
},
onEachFeature: onEachFeature
});
var map = L.map('map', {
layers: [
base_map,
over_geojson_station,
over_geojson_sjy_bound_2nd
],
minZoom: 6,
maxZoom: 17,
zoomIn: 1,
zoomOut: 1,
zoomControl: false
}).setView([34, 96], 6);
var bounds = new L.LatLngBounds(new L.LatLng(31, 103), new L.LatLng(38, 89));
map.fitBounds(bounds);
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
map.invalidateSize();
});
}