Hi
Could someone help me out, I still didn't figure this out.
My original code, works fine:
function load() {
if (GBrowserIsCompatible()) {
geocoder = new GClientGeocoder();
map = new GMap2(document.getElementById('map'));
map.enableDoubleClickZoom();
map.enableScrollWheelZoom();
map.addControl(new TextualZoomControl());
var center = new GLatLng(50.823841,4.359491); // brussels center
50.823841,4.359491
map.setCenter(center, 13);
searchLocations();
}
}
GSearch.setOnLoadCallback(load);
But when I try to integrate the User Locator from Google,
http://allmybookings.com/userlocator.php (this version working), into
my code, it doesn't work.
Thanks in advance,
Sebastian
On Mar 1, 7:00 pm, sebastian de comocomo <[email protected]>
wrote:
> Hi Jeremy,
>
> I put the callback as you mentioned, and I deleted the other callback in the
> function.
>
> I don't understand what you mean by "groups will screw it up". ;o)
>
> I like the new logic structure, but I can't make it work.
>
> I made a few changes, I don't know is this might affect.
>
> google.load("maps", "2.x"); (instead of)google.load('maps','2');
>
> if (GBrowserIsCompatible()) { // 2 open (instead of)
> if(google.maps.BrowserIsCompatible()){
>
> The last code version is:
>
> google.load("maps", "2.x");
> function load(){ // 1open
> if (GBrowserIsCompatible()) { // 2 open
> var lat,lng,location;
> if(google.loader.ClientLocation){ //3open
> var cl=google.loader.ClientLocation;
> lat=cl.latitude;
> lng=cl.longitude;
>
> location= [cl.address.city,cl.address.region,cl.address.country].join(',
> ');
> } // 3cclose
> else { // 4 open
> lat=0; // default lat
> lng=0; // default lng
> location="CAN'T FIND YOURLOCATION";
> document.getElementById('cantfindyou').innerHTML=location;
> } //4close
> createMap(lat,lng,location);
> } // 2close
>
> } // 1 close
>
> function createMap(lat, lng,location) { // 1open
> var mapElement = document.getElementById("map");
> mapElement.style.display = 'block';
> var map = newgoogle.maps.Map2(mapElement);
> map.addControl(new GLargeMapControl());
> map.addControl(new GMapTypeControl());
> map.setCenter(newgoogle.maps.LatLng(lat, lng), 13);
>
> } // 1close
>
> google.setOnLoadCallback(load);
>
> searchLocations();
>
> On 01/03/09 14:20, "Jeremy Geerdes" <[email protected]> wrote:
>
>
>
> > 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 YOURLOCATION";
> > 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 theGoogleUserLocationwith theGoogleStore
> >> Locator.
>
> >> I've tried many combinations, but I don't manage to make it work.
>
> >> I'd like 1st. to detect theUserLocation, if so pass thelocationto
> >> the Store Locator, and if not pass a fixed maplocation.
>
> >> Here is the working code for theUserDetection:
>
> >>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 theUser
> >> 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;
> >> varlocation= [cl.address.city, cl.address.region,
> >> cl.address.country].join(', ');
>
> >> createMap(cl.latitude, cl.longitude,location);
> >> } else {
> >> document.getElementById('cantfindyou').innerHTML = "CAN'T FIND
> >> YOURLOCATION";
> >> createMap(0,0,"CAN'T FIND YOURLOCATION");
>
> >> }
> >> });
>
> >> function createMap(lat, lng,location) {
> >> var mapElement = document.getElementById("map");
> >> mapElement.style.display = 'block';
> >> var map = newgoogle.maps.Map2(mapElement);
> >> map.addControl(new GLargeMapControl());
> >> map.addControl(new GMapTypeControl());
> >> map.setCenter(newgoogle.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
-~----------~----~----~----~------~----~------~--~---