Limiting Google Maps to a specific country

5,268 views
Skip to first unread message

Avinash Javaji

unread,
Dec 24, 2011, 5:08:38 AM12/24/11
to google-map...@googlegroups.com
Hi,

   I'm rather new to Google Maps API and pretty new to using APIs itself, however I have done a fair amount research before asking this: is it possible to limit the map to a specific area, for example, to a specific country like India? I know I can limit the zoom and monitor the draggable events to ensure the user only views a specific area, but I would like to completely remove other areas (in this case all countries other than India) from the map.

Any information would be greatly appreciated, even far fetched solutions.

Thank You.

Barry Hunter

unread,
Dec 27, 2011, 5:58:23 PM12/27/11
to google-map...@googlegroups.com
I think the closest can do is something like this example
http://maps.forum.nu/gm_texas.html

it just draws a shape over the top of the other areas - making a map
just showing Texas.

> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/google-maps-js-api-v3/-/B7y9klfJE7YJ.
> To post to this group, send email to google-map...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-maps-js-a...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Avinash Javaji

unread,
Dec 28, 2011, 10:37:01 AM12/28/11
to Google Maps JavaScript API v3
Thank you for your response. I have seen that example. I agree it is
one of the best solutions available. However it isn't all that great.
When you zoom or pan around, it takes a while to show the overlay
tiles. Generally it isn't a very clean way to do it. So I'm looking
for any other possible solutions.

Avinash

On Dec 28, 3:58 am, Barry Hunter <barrybhun...@gmail.com> wrote:
> I think the closest can do is something like this examplehttp://maps.forum.nu/gm_texas.html

Marcelo

unread,
Dec 28, 2011, 11:22:19 AM12/28/11
to Google Maps JavaScript API v3
On Dec 28, 8:37 am, Avinash Javaji <avinashjav...@gmail.com> wrote:
> Thank you for your response. I have seen that example. I agree it is
> one of the best solutions available. However it isn't all that great.
> When you zoom or pan around, it takes a while to show the overlay
> tiles. Generally it isn't a very clean way to do it. So I'm looking
> for any other possible solutions.

Keep in mind that my site is hosted on a shared server, which is not
optimal for performance, and also, I do not have mirror servers in
India, like Google does.
An alternative to the custom tiles approach could be a GroundOverlay
covering the entire world, and with a transparent "hole" in the shape
of the country you want to show. This is similar to that approach,
(V2):
http://maps/temp/gm_rounded_corners.html

... but it uses GOverlay instead of GGroundOverlay, so it does not
scale when you zoom in and out:

--
Marcelo - http://maps.forum.nu
--

Marcelo

unread,
Dec 28, 2011, 11:26:56 AM12/28/11
to Google Maps JavaScript API v3
On Dec 28, 9:22 am, Marcelo <marcelo...@hotmail.com> wrote:
> http://maps/temp/gm_rounded_corners.html

OOPSS! Wrong URL. This is the right one:
http://maps.forum.nu/temp/gm_rounded_corners.html

--
Marcelo - http://maps.forum.nu
--




>
> ... but it uses GOverlay instead of GGroundOverlay, so it does not
> scale when you zoom in and out:
>
> --
> Marcelo -http://maps.forum.nu

Avinash Javaji

unread,
Dec 29, 2011, 9:49:23 AM12/29/11
to Google Maps JavaScript API v3
Hm yea, but it isn't of much use I guess cause it doesn't scale. But
thanks anyway, I didn't know I could do this.

On Dec 28, 9:26 pm, Marcelo <marcelo...@hotmail.com> wrote:
> On Dec 28, 9:22 am, Marcelo <marcelo...@hotmail.com> wrote:
>
> >http://maps/temp/gm_rounded_corners.html
>
> OOPSS! Wrong URL. This is the right one:http://maps.forum.nu/temp/gm_rounded_corners.html
>
> --
> Marcelo -http://maps.forum.nu

Rossko

unread,
Dec 29, 2011, 6:31:22 PM12/29/11
to Google Maps JavaScript API v3
> Hm yea, but it isn't of much use I guess cause it doesn't scale.

Yes, you'd have to do some of your own development and adapt the
technique to a ground overlay
http://code.google.com/apis/maps/documentation/javascript/overlays.html#GroundOverlays

Avinash Javaji

unread,
Dec 30, 2011, 2:35:07 AM12/30/11
to Google Maps JavaScript API v3
Yea I guess I'll have to experiment with that. I shall go work on it.
Hopefully I can come up with something.

On Dec 30, 4:31 am, Rossko <ros...@culzean.clara.co.uk> wrote:
> > Hm yea, but it isn't of much use I guess cause it doesn't scale.
>
> Yes, you'd have to do some of your own development and adapt the
> technique to a ground overlayhttp://code.google.com/apis/maps/documentation/javascript/overlays.ht...

Berry Ratliff

unread,
Dec 30, 2011, 10:04:59 AM12/30/11
to Google Maps JavaScript API v3
On Dec 30, 7:35 am, Avinash Javaji <avinashjav...@gmail.com> wrote:
> Yea I guess I'll have to experiment with that. I shall go work on it.
> Hopefully I can come up with something.

It can be done in an "OverlayView" using CANVAS:

http://home.provide.net/~bratliff/polycluster/experiment/hawaii.html

http://home.provide.net/~bratliff/polycluster/experiment/alaska.html

Click the "Reverse" button to invert the poly.
Reply all
Reply to author
Forward
0 new messages