Your code doesn't work because of the way you're using  
google.setOnLoadCallback.  Specifically, you use it once to set the  
onload listener to the load function, and then inside the load  
function, you set it to a function that will create your map, etc.   
You need something more like this:

google.load('maps','2');
function load(){
  if(google.maps.BrowserIsCompatible()){
   var lat,lng,location;
   if(google.loader.ClientLocation){
    var cl=google.loader.ClientLocation;
    lat=cl.latitude;
    lng=cl.longitude;
     
location 
=[cl.address.city,cl.address.region,cl.address.country].join(', ');
   } else {
    lat=0; // default lat
    lng=0; // default lng
    location="CAN'T FIND YOUR LOCATION";
    document.getElementById('cantfindyou').innerHTML=location;
   }
   createMap(lat,lng,location);
  }
}

function createMap(lat, lng, location){
  ...
}

google.setOnLoadCallback(load);


Beware the formatting of this code snippet!  Groups will screw it up!

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
http://jgeerdes.blogspot.com
http://jgeerdes.wordpress.com
[email protected]

Unless otherwise noted, any price quotes contained within this  
communication are given in US dollars.

If you're in the Des Moines, IA, area, check out Debra Heights  
Wesleyan Church!

And check out my blog, Adventures in Web Development, at 
http://jgeerdes.blogspot.com 
  !


On Mar 1, 2009, at 5:34 AM, Sebastian wrote:

>
> Hi,
>
> Could someone help me?
>
> I'm trying to integrate the Google User Location with the Google Store
> Locator.
>
> I've tried many combinations, but I don't manage to make it work.
>
> I'd like 1st. to detect the User Location, if so pass the location to
> the Store Locator, and if not pass a fixed map location.
>
> Here is the working code for the User Detection:
>
> http://allmybookings.com/userlocator.php
>
> and here is the code, "integrated", but not really working. Any other
> combinations create a conflict. This one, just goes through the User
> Locator code, but prints the map.
>
> google.load("maps", "2.x");
>
> function load() {
>      if (GBrowserIsCompatible()) {
>
> google.setOnLoadCallback(function() {
>    if (google.loader.ClientLocation) {
>        var cl = google.loader.ClientLocation;
>        var location = [cl.address.city, cl.address.region,
> cl.address.country].join(', ');
>
>        createMap(cl.latitude, cl.longitude, location);
>    } else {
>        document.getElementById('cantfindyou').innerHTML = "CAN'T FIND
> YOUR LOCATION";
>                           createMap(0,0,"CAN'T FIND YOUR LOCATION");
>
>    }
> });
>
> function createMap(lat, lng, location) {
>    var mapElement = document.getElementById("map");
>    mapElement.style.display = 'block';
>    var map = new google.maps.Map2(mapElement);
>    map.addControl(new GLargeMapControl());
>    map.addControl(new GMapTypeControl());
>    map.setCenter(new google.maps.LatLng(lat, lng), 13);
>    map.openInfoWindow(map.getCenter(), document.createTextNode
> (location));
> }
>        geocoder = new GClientGeocoder();
>        map = new GMap2(document.getElementById('map'));
>               map.enableDoubleClickZoom();
>               map.enableScrollWheelZoom();
>        map.addControl(new TextualZoomControl());
>
>
>               var center = new GLatLng(50.,4.359491); // brussels center
> 50.823841,4.359491
>        map.setCenter(center, 13);
>
>                               searchLocations();
>      }
>    }
>      GSearch.setOnLoadCallback(load);
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-AJAX-Search-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to