I am not receiving any errors in the console either. I am attempting to use the Promise function instead of callback.
var map; var centerlatlng = L.latLng(38, -98); var aDiv; var geojsonfeatures;
$(document).ready(function (){
var aLayerOne = L.tileLayer('http://ift.tt/1rCy3iO', {
attribution: '© <a href="http://ift.tt/ItuEqj">OpenStreetMap</a>, Tiles courtesy of <a href="http://ift.tt/TAmVxC" target="_blank">Humanitarian OpenStreetMap Team</a>'
});
var aLayerTwo = L.tileLayer('http://ift.tt/1ANv7mr}', {
attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
});
var aLayerThree = L.tileLayer('http://ift.tt/1xBaPsU', {
attribution: 'Map data © <a href="http://ift.tt/ScoM9f">OpenWeatherMap</a>',
opacity: 0.5
});
var aLayerFour = L.tileLayer('http://ift.tt/1rCy4mC', {
attribution: 'Map data © <a href="http://ift.tt/ScoM9f">OpenWeatherMap</a>',
opacity: 0.5
});
var aLayerFive = L.tileLayer('http://ift.tt/1rCy4mE', { attribution: 'Map data © OpenWeatherMap', opacity: 0.5 });
var points = L.geoJson(geojsonfeatures, { filter: function(feature, layer) { return feature.properties.COUNTRY != "UNITED STATES"; }, pointToLayer: function(feature, latLng) { return L.marker(latLng)
.bindPopup(feature.properties.NAME);
}// end of function
});
map = L.map('myMap', {
center: centerlatlng,
zoom: 4,
layers: [aLayerOne]
});
var promise = $.getJSON("js/weatherstations.js");
promise.then(function(geojsonfeatures) {
var weatherstations = L.geoJson(geojsonfeatures);
points.addTo(map)
// Add a Layers Control
var baseMaps = {
"Open Street Map HOT": aLayerOne,
"Esri Imagery": aLayerTwo
};
var overLays = {
"Precipitation": aLayerThree,
"Temperature": aLayerFour,
"Barometric Pressure": aLayerFive,
"California Weather Stations":weatherstations
};
L.control.layers(baseMaps, overLays).addTo(map);
// Add a Scale Control
L.control.scale().addTo(map);
// Add a Full Screen Control
// use "new" in its construct
new L.Control.FullScreen().addTo(map);
// Add a Locate Control
// images folder must be within the same folder as L.Control.Locate.css file
L.control.locate().addTo(map);
///Creating custom control here
// part 1/3 : Creates a control with the given position
var aControl = L.control({ position: 'bottomright' });
// part 2/3 : Should contain code that creates all the neccessary DOM elements for the control
aControl.onAdd = function () {
aDiv = L.DomUtil.create('div', 'aCustomC'); // create a div with a class "aCustomC"
aDiv.innerHTML = "Open-Source Weather Map"; // Each HTML element has an innerHTML property that defines both the HTML code and the text that occurs between that element's opening and closing tag.
return aDiv;
}; // end function onAdd
// part 3/3 : Add the control to the map
aControl.addTo(map);
////////
var searchControl = new L.esri.Controls.Geosearch().addTo(map);
var results = new L.LayerGroup().addTo(map);
searchControl.on('results', function (data) {
results.clearLayers();
for (var i = data.results.length - 1; i >= 0; i--) {
results.addLayer(L.marker(data.results[i].latlng));
}
});
$('.aToolTip').tooltip({
'container': 'body'
}); // this works
$('.aPopOver').popover({
'container': 'body'
});// this works
});
});
Aucun commentaire:
Enregistrer un commentaire