无法使用Google地图数据图层从源加载geojson

时间:2014-08-08 06:22:22

标签: javascript google-maps google-maps-api-3 geojson

我从publicly available dataset here获得了saved here的geoJSON数据集。

当我从系统上的文件将数据加载到Google Maps Data Layer时:

var goldCoastData = new google.maps.Data({
    map: map,
    style: {
        icon: 'images/marker_gc.png',
        strokeColour: '#0b2430',
        strokeOpacity: 1,
        fillColor: '#ff534f',
        fillOpacity: 1
    }
});

$.ajax({
    type: 'GET',
    url: 'scripts/datasets/goldCoast_buildings.json',
    dataType: 'json'
}).done(function (data) {
    console.log(JSON.stringify(data));
    goldCoastData.addGeoJson(data);
});

数据未显示在地图上。我对数据进行了以下检查:

  1. jsonlint(全成)
  2. geojsonhint(成功)的
  3. geojsonlint不确定/失败???
  4. drag and drop失败

1 个答案:

答案 0 :(得分:2)

我发现添加到geoJson google maps的{​​{1}}需要使用投影Data layer才能工作。我可以从此处获取数据集中的数据格式使用& SrsName = EPSG:4326在网址末尾。

This links to data from the question in the correct format

从评论到@geocodezip和@JohnBarça提出的问题,谷歌使用EPSG:3857,所以这肯定是某种怪癖。

相关问题