jQuery 和谷歌地图 JSON
我的代码遇到了一个小问题,它似乎停在 JSON 文件中的 10 个列表处
,并且 JSON 文件返回了 300 多条记录,有人请告诉我哪里出了问题
DEMO http://realcashback.com.au/development/maps.php
var map;
var businessaddress;
var marker;
function initialize() {
var myOptions = {
zoom: 1,
center: new google.maps.LatLng(-37.810013, 144.962683),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
getlocations();
}
google.maps.event.addDomListener(window, 'load', initialize);
function getlocations(){
$.getJSON('http://realcashback.com.au/development/system/classes/core.php?task=listmyleads', function(data) {
$.each(data, function(i, obj) {
businessname = obj.TradingName;
if(!obj.suburb)
{
businessaddress = obj.street+", "+obj.suburb+" "+obj.state+" "+obj.postcode;
showAddress(businessaddress,businessname);
}
});
});
}
function showAddress(address,name) {
//alert(address);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
latlngCity = results[0].geometry.location;
// alert(latlngCity);
marker = new google.maps.Marker({
position: latlngCity,
title:name
});
// To add the marker to the map, call setMap();
marker.setMap(map);
}
});
}
I am having a small issue with my code it seems to stop at 10 listings in the JSON file
and the JSON file comes back with 300+ records would someone please tell me where I have gone wrong
DEMO
http://realcashback.com.au/development/maps.php
var map;
var businessaddress;
var marker;
function initialize() {
var myOptions = {
zoom: 1,
center: new google.maps.LatLng(-37.810013, 144.962683),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'),
myOptions);
getlocations();
}
google.maps.event.addDomListener(window, 'load', initialize);
function getlocations(){
$.getJSON('http://realcashback.com.au/development/system/classes/core.php?task=listmyleads', function(data) {
$.each(data, function(i, obj) {
businessname = obj.TradingName;
if(!obj.suburb)
{
businessaddress = obj.street+", "+obj.suburb+" "+obj.state+" "+obj.postcode;
showAddress(businessaddress,businessname);
}
});
});
}
function showAddress(address,name) {
//alert(address);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address}, function(results, status) {
if(status == google.maps.GeocoderStatus.OK) {
latlngCity = results[0].geometry.location;
// alert(latlngCity);
marker = new google.maps.Marker({
position: latlngCity,
title:name
});
// To add the marker to the map, call setMap();
marker.setMap(map);
}
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你只是想展示那些没有郊区的。
它显示直到约翰登陆露营地的所有点 - 它不显示“黄金海岸直升机之旅”。
也许是 TradingName 中前导空格和尾随空格的问题?
You are only trying to show the ones without a suburb.
It displays all points up until Johns Landing Camping Ground - it does not show " Gold Coast Helitours ".
Perhaps an issue with the leading and trailing spaces in the TradingName?