大家好,我使用 openlayer 开发 web 地图。
我使用geojson,我的代码来自: https ://scraperwiki.com/views/openlayers_geojson_example/edit/
这是代码:
<script type="text/javascript">
// Start position for the map (hardcoded here for simplicity)
var lat=50.90685
var lon=-1.4029
var zoom=12
var map; //complex object of type OpenLayers.Map
//Initialise the 'map' object
$(function() {
$.getJSON("http://mapit.mysociety.org/area/66016.geojson",
"callback=?",
function(data, textStatus, jqXHR) {
map = new OpenLayers.Map('map', {
layers: [
new OpenLayers.Layer.OSM.Mapnik("Mapnik"),
],
controls: [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.LayerSwitcher(),
new OpenLayers.Control.Attribution()],
maxResolution: 'auto',
});
var lonLat = new OpenLayers.LonLat(lon, lat)
.transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
map.setCenter(lonLat, zoom);
var vector_layer = new OpenLayers.Layer.Vector("GeoJSON");
var geojson_format = new OpenLayers.Format.GeoJSON();
var geometry = geojson_format.parseGeometry(data);
geometry.transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
);
var feature = new OpenLayers.Feature.Vector(geometry);
vector_layer.addFeatures([feature]);
map.addLayer(vector_layer);
})
});
</script>
在 :
$.getJSON("http://mapit.mysociety.org/area/66016.geojson",
"callback=?",
当我从 iis localhost 调用时它可以工作我尝试像这样更改:
$.getJSON("assets/json/66016.geojson",
"callback=?",
但它没有用,:(
请帮助我为什么以及如何使这项工作。
这是错误的:
HTTP 错误 404.0 - 未找到 localhost --- >/assets/json/66016.geojson?callback=jQuery152048599341535009444_1366340277133&_=1366340277237