0

im including this librarys into my page,

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places,geometry&sensor=true"></script>

i'm searching for a url-parameter that restricts the librarys only for one country. I thought i have seen something like this but i can't find it in the docs anymore and googling does not bring me to something usefull.

Update : here are some further informations

Im using two things
places autocomplete, already with restriction :

var options = {
  types: ['geocode'],
  componentRestrictions: {country: 'de'}
};
autocomplete = new google.maps.places.Autocomplete(input, options);

And also have a geocoder for some cases, also with restriction :

geocoder.geocode({"address":address,"country":"de" }, function(results, status) {...

But somehow when I geocode for example "ho"

the returned formatted Address is " Ho, Ghana Africa", and that is definetly not in Germany

another example is geocoding "21029" (a german zip-code) results in Clarksville, Maryland 21029, USA , wich also is not in germany Any Help ?

Thanks in advance

john Smith
  • 17,409
  • 11
  • 76
  • 117
  • Is this what you are looking for? https://developers.google.com/maps/documentation/javascript/3.exp/reference#ComponentRestrictions – geocodezip Nov 14 '13 at 16:53
  • just updated my question – john Smith Nov 14 '13 at 19:14
  • possible duplicate of [How to prevent google geocoder from returning results from other countrys](http://stackoverflow.com/questions/19989653/how-to-prevent-google-geocoder-from-returning-results-from-other-countrys) – john Smith Nov 14 '13 at 23:12

1 Answers1

1

So, I'm gathering you wanted to use Google's Map API and restrict the view to only one country - unsure, but I think that's what you want.

Regardless, I did some searching and ended up finding a solution on Stack Overflow. Google Maps v3 - limit viewable area and zoom level

In case you simply just read the selected answer rather than reading through the thread, I'd suggest using the following lines of JS to just restrict the zooming around the map a user could do. I don't take credit for this myself (although it's simply configuration), as I've barely used Google's map API, but this was written by ChrisV.

var opt = { minZoom: 6, maxZoom: 9 };
map.setOptions(opt);

Although, if you were aiming to do something much more in depth and interactive then the selected answer might be helpful as he goes on to test for x,y within the map and specifically uses North America in his code.

Community
  • 1
  • 1
eric
  • 170
  • 1
  • 9
  • i just added some more information to my question, i´m already using "country" like in your link but i got results from elsewhere – john Smith Nov 14 '13 at 19:12