您的问题是 ID 号比属性子对象高一级。GeoJSON 的布局如下:
var statesData = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "01",
"properties": {
"name": "Alabama",
"density": 94.65
},
"geometry": {
//continues on for a long time...
中的代码highlightFeature function
,即在 MouseOver 上运行的代码,传入 object layer.feature.properties
。然后这成为props
你的功能。如果您查看 GeoJSON,它比 ID 值低一级。
要解决此问题,layer.feature
请改为传入,并将您的函数更改为以下内容:
info.update = function (feature) {
if (feature) {
var props = feature.properties;
propsState = props.State; //StateName
propsName = props.name; //CountyName
propsID = feature.id; //NOTE we are using feature here, NOT props
propsRanking = props.Ranking;
}
};