我正在尝试创建一个非常简单的弹出窗口,它从(点)geoJson属性中提取信息

时间:2016-04-21 17:49:00

标签: popup leaflet geojson

我使用以下代码,它只是不起作用!使用点geoJson。

这种类型的代码在几步后用于多边形geoJson。

js:

 var points2 = L.geoJson(points2,{onEachFeature: function(feature, layer) {
 layer.bindPopup(feature.properties.popup);}}).addTo(map);

相关的geojson:

var points2 = {"type": "FeatureCollection", "features":

[
{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.997208,40.743771]},"properties":{"cartodb_id":2,"description":"Private home","popup":"Casa Señora Arnao (Bernardo's 1st abode in NYC)","address":"228 West 22nd Street"}},

{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.926637,40.858235]},"properties":{"cartodb_id":5,"description":"Urban scene","popup":"Couples kissing openly - \"I quickly realized that our presence didn’t matter to them….what a difference between our customs back home and the behavior of Puerto Rican men and women in New York!”","address":"Park at 191st Street and St-Nicholas Avenue"}},

{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.95678,40.805015]},"properties":{"cartodb_id":4,"description":"Private home","popup":"Casa Familia León","address":"116th Street and Manhattan Avenue"}},

{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.949677,40.797255]},"properties":{"cartodb_id":7,"description":"Political/Cultural meeting place","popup":"Park Palace","address":"3-5 West 110th Street"}},

{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.9467,40.790554]},"properties":{"cartodb_id":8,"description":"Political/Cultural meeting place","popup":"Harlem Terrace","address":"210 East 104th Street"}},

{"type":"Feature","geometry":{"type":"Point","coordinates":[-73.948755,40.793271]},"properties":{"cartodb_id":9,"description":"Political/Cultural meeting place","popup":"Harlem Educational Center","address":"106th Street (between Park and Madison Aves)"}}

]}

可能导致错误的原因是什么?如何解决?

感谢。

0 个答案:

没有答案