Geolocation shows nothing if user closes prompt box without allowing or denying

268 views
Skip to first unread message

Signed To Find

unread,
Jul 2, 2011, 3:49:50 AM7/2/11
to google-map...@googlegroups.com
Hey All

I utilising the GEOLOCATION CODE" from the google examples library but have a problem. When you load the map in various broswers like Firefox or Chrome if the users doesn't agree to either allow/deny and dismisses the prompt by clicking close button [X] the map doesn't display.

Is it possible to have the map load a default location still, same to the location if the user deny's access?

thanking you in advance
Jacko

Pil

unread,
Jul 3, 2011, 2:24:43 AM7/3/11
to Google Maps JavaScript API v3
If you mean this example

http://code.google.com/apis/maps/documentation/javascript/examples/map-geolocation.html

thats because no center of the map is defined if the user refused to
interact.
Insofar you are right. You should make it better in your own map.

Mitchell Erickson

unread,
Aug 18, 2011, 6:18:09 PM8/18/11
to Google Maps JavaScript API v3
You may have solved this problem already, but here's a reply anyway.
If I'm understanding you correctly, I was having the same problem.
Pil's message has a link to an example that has this problem--that is,
if the user refused geolocation, then no map appears. I've solved this
problem for a website I'm working on, but I'm not sure it would be
appropriate for your website--it depends on what you want. When a user
goes to my page, a default map is already loaded. The "pop up" asking
for permission to geolocate appears, also. If the user denies
geolocation, the default map stays on the page, but if they agree to
geolocation, a new map centered on their location appears. Basically,
it's pretty simple. Before the geolocation code (//Try W3C Geolocation
(Preferred)-- in the code in the link) just create a new map. This map
will be replaced by the geolocated map. I'm sure you know how to
create this default map, but here is the code anyway:

var myOptions = {
zoom: 12,
center: seattle, // "seattle" is a variable that is initialized
previously as a new google.maps.LatLng
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);

//after this the geolocation code appears

Vivek Shingala

unread,
Oct 13, 2011, 7:19:17 AM10/13/11
to google-map...@googlegroups.com
thanks yaar.
Reply all
Reply to author
Forward
0 new messages