我正在尝试使用 JavaScript API 中的 MapQuest 地理编码模块来动态批处理地理编码地址:
MQA.withModule('geocoder', function() {
var addresses = new Array();
$.getJSON('get_marker_json.php', function( data ) {
$.each(data, function(i, item) {
addresses.push(street: item.address, city: item.city, state: item.state, postalCode: item.zip);
});
});
/*Pass an array of locations to be geocoded and placed on map*/
map.geocodeAndAddLocations(
// add addresses from array here
addresses
);
});
但是,这不起作用。似乎必须预先定义地址。例如:
map.geocodeAndAddLocations([
'Littleton CO',
{ city: 'Steamboat Springs', state: 'CO' },
{ street: '555 17th St', postalCode: '80202' },
'Winter Park CO'
]);
我怎样才能做到这一点?
谢谢!