/    Sign up×
Community /Pin to ProfileBookmark

Google Maps Geocoder

Hello,

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. [url]https://groups.google.com/forum/?fromgroups=#!topic/google-maps-js-api-v3/FKvDIa0P1bw[/url] 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>
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@xelawhoJan 16.2013 — 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.
[/QUOTE]
Copy linkTweet thisAlerts:
@WebmastergraceJan 17.2013 — Hello,

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/?fromgroups=#!topic/google-maps-js-api-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>
[/CODE]
[/QUOTE]


Thanks to share this info with us.
×

Success!

Help @jcbrmn06 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...