I'm trying to create a simple "Green" map for my city. The idea being that it is a website with a map and layers you can turn on and off. I am serving the data through GeoServer and am using GeoJOSN to add the data to the map. I checked the URL for the data and GeoServer is serving up the file in GeoJOSN format.
Eventually I would like to be able to let the user to click on the points on each layer to get more information but I need to get the data showing up on the map first. The leaflet code below is pretty simple but I can't seem to get the data to show up on the map. I refereed to the Leaflet documentation but can't figure it out.
I'm guessing I am just leaving something simple out due to my lack of knowledge about Leaflet. Leaflet web mapping ninja's, a little help please.
<div id="map" style="height: 600px"></div>
<script src="./dist/leaflet.js"></script>
<script>
var map = new L.Map('map');
var cloudmade = new L.TileLayer('http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png', {
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://cloudmade.com">CloudMade</a>',
maxZoom: 18
});
var chattanooga = new L.LatLng(35.0431, -85.2379); // geographical point (longitude and latitude)
map.setView(chattanooga, 13).addLayer(cloudmade);
var geojsonLayer = new L.GeoJSON();
function loadGeoJson(data) {
geojson.addGeoJSON(data);
}
var geoJsonUrl = "http://localhost:8080/geoserver/ows?service=WFS&version=1.1.0&request=GetFeature&typeName=Farmers_Markets&srsName=EPSG:2274&outputFormat=json&format_options=callback:loadGeoJson";
$.ajax({
url: geoJsonUrl,
dataType: 'jsonp'
});
map.addLayer(geojsonLayer);
</script>