I am have added a google map to my website successfully, the only problem is that I have 16 different locations and only 11 of them are showing up. I have done some research into this and Google has limited the number of request on a load, which in this case would be 11. I found a few places saying that if you put a specific time limit on the request you can load more locations. One example is here. https://groups.google.com/forum/?fro...v3/FKvDIa0P1bw I was just wondering if anyone would know how to do that same thing but make it function with my code. My code is pasted below. Any help in the right direction would be greatly appreciated.
Code:
<script type="text/javascript" src="http://tropitan.biz/wp-content/themes/tropitan/js/jquery.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDbsdaxW8es67YUELxpATte1jBbABTVZQQ&sensor=false"></script>
<script type="text/javascript">
$("#bigmap").prepend('<div id="map_canvas"></div>');
$(".static_map").remove();
var bounds;
var geocoder;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(42.970625, -83.777093),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
geocoder = new google.maps.Geocoder();
bounds = new google.maps.LatLngBounds();
}
function addMarkerToMap(location){
var marker = new google.maps.Marker({map: map, position: location});
bounds.extend(location);
map.fitBounds(bounds);
}
initialize();
$("address").each(function(){
var $address = $(this);
geocoder.geocode({address: $address.text()}, function(results, status){
if(status == google.maps.GeocoderStatus.OK) addMarkerToMap(results[0].geometry.location);
});
});
</script>
where do your 16 locations come from? are they decided by you or the user? Because if you know them in advance, to me it seems the best advice is from the forum thread that you posted:
The general advice is not to geocode addresses everytime your page
loads. Geocode them once, offline, then use the resulting coordinates
to display the markers.
Geocoding the addresses every time wastes google's resources, so they
have implemented rate limits and quotas. You should only geocode
addresses you don't know in advance (like user input) on the fly.
I am have added a google map to my website successfully, the only problem is that I have 16 different locations and only 11 of them are showing up. I have done some research into this and Google has limited the number of request on a load, which in this case would be 11. I found a few places saying that if you put a specific time limit on the request you can load more locations. One example is here. https://groups.google.com/forum/?fro...v3/FKvDIa0P1bw I was just wondering if anyone would know how to do that same thing but make it function with my code. My code is pasted below. Any help in the right direction would be greatly appreciated.
Code:
<script type="text/javascript" src="http://tropitan.biz/wp-content/themes/tropitan/js/jquery.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDbsdaxW8es67YUELxpATte1jBbABTVZQQ&sensor=false"></script>
<script type="text/javascript">
$("#bigmap").prepend('<div id="map_canvas"></div>');
$(".static_map").remove();
var bounds;
var geocoder;
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(42.970625, -83.777093),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
geocoder = new google.maps.Geocoder();
bounds = new google.maps.LatLngBounds();
}
function addMarkerToMap(location){
var marker = new google.maps.Marker({map: map, position: location});
bounds.extend(location);
map.fitBounds(bounds);
}
initialize();
$("address").each(function(){
var $address = $(this);
geocoder.geocode({address: $address.text()}, function(results, status){
if(status == google.maps.GeocoderStatus.OK) addMarkerToMap(results[0].geometry.location);
});
});
</script>
Bookmarks