Patricia
Patricia

Reputation: 7802

Google Maps API on Localhost Issue

I'm brand new to working with the google maps api, and i've been stuck on this for a while now. i searched around and couldn't find much on why this is happening.

the problem seems to be with this request: http://maps.googleapis.com/maps/api/js/AuthenticationService.Authenticate?1shttp%3A%2F%2Flocalhost%2FjQUeryMobile%2FHome%2FContact&callback=xdc._g5hc9f&token=122839

the bold part is obviously a problem. this parameter doesn't seem to be being built properly.

i don't have any control over this though, this is all done by the maps stuff.

here's my line for including the maps script:

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false&callback=initializeGeoCoder"></script>


    function initializeGeoCoder(){
        alert('initialize');
        geoCoder = new GClientGeocoder();
    }

interestingly enough, that alert does fire, but then nothing happens.

maybe important details about my setup:

i'm running iis locally on windows 7. the project is a .net 3.5 mvc 2.0 project. with jquery and jquery mobile.

i've tried it in FF, chrome, safari and IE.

is it really a case of the api not being able to handle running on localhost? how does anyone do any testing?

EDIT: looking into this even further, i looked at the requests for some of the samples. http://code.google.com/apis/maps/documentation/javascript/examples/map-simple.html

it has a request pretty well the same: http://maps.googleapis.com/maps/api/js/AuthenticationService.Authenticate?1shttp%3A%2F%2Fcode.google.com%2Fapis%2Fmaps%2Fdocumentation%2Fjavascript%2Fexamples%2Fmap-simple.html&callback=xdc._56yxp&token=74698

which returns:

_xdc_._56yxp && _xdc_._56yxp( [1,null,0] )

mine returns:

_xdc_._10kda1 && _xdc_._10kda1( [1,null,0] )

i originally thought this was gibberish b/c of the request url being bad. but it seems that might not be the case.

some more information:

when running in IE, with script debugging running: this line fails:

EDIT: More Information:

when running it in IE, with script debugging. i get an error on this line:

geoCoder = new GClientGeocoder();

the error is:

'GClientGeocoder' is undefined

so: something from the maps api isn't getting loaded all the way it seems.

Upvotes: 9

Views: 15895

Answers (1)

Derek
Derek

Reputation: 4931

You're going to need to post more code than that. Post the div which contains your map.

The GClientGeocoder function doesn't insert a map into your page. In fact, it does something completely different (input an address and it will return lat/long).

Use this tutorial to start with a simple Google map.

http://code.google.com/apis/maps/documentation/javascript/tutorial.html

EDIT: If you are trying to use geocoding, then V3 of the Google Maps API names the function geocode() rather than GClientGeocoder(). Check out the source code of this demo: http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-simple.html

Upvotes: 3

Related Questions