与我的geoJson相关的标记未填充到我的地图上。如果我在http://geojsonlint.com/上运行我的geoJSON,它一切正常。如果我将我的geoJSON与Google Maps dev api 'https://storage.googleapis.com/maps-devrel/google.json'
中的示例互换,那么它们的覆盖图会填充到我的地图上。有效的geoJson未填充Google地图标记
下面我运行http://localhost:3009/murals.json
作为loadGeoJson
的参数我也试过从本地文件运行test.json
。
我的地图.js文件
function initialize() {
var myLatlng = new google.maps.LatLng(40.0172679,-105.2839094);
var myOptions = {
zoom: 16,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(
document.getElementById('map'), myOptions
);
map.data.loadGeoJson('http://localhost:3009/murals.json');
};
google.maps.event.addDomListener(window, "load", initialize());
我控制器(无疑会进行重构,但输出正确的格式以GeoJSON)
def index
@murals = Mural.all
muralHash = []
@geojson = { type: "GeometryCollection",
geometries: muralHash
}
@murals.each do |mural, myHash = {:type => nil,:coordinates => nil}|
myHash["type"] = 'Point'
myHash["coordinates"] = [mural.longitude, mural.latitude]
muralHash << myHash
end
respond_to do |format|
format.html
format.json { render json: @geojson }
end
end
GeoJSON的
{ "type":"GeometryCollection",
"geometries":[
{
"type":"Point",
"coordinates":[-105.287685950293,40.0124034482671]
},
{
"type":"Point",
"coordinates":[-105.196297724738,39.9935339839196]
},
{
"type":"Point",
"coordinates":[-105.283136923804,40.0162490232761]
}
]
}
请发布JSON – 2014-12-03 18:22:59
@ Dr.Molle补充 – Jadam 2014-12-03 18:26:40