On Oct 17, 3:35 pm, Robert Church <[email protected]> wrote:
> I have a web page the allows users of the system to check in - a proof of
> sorts that they were at a location. It tracks their long/lat and saves it
> into a database record. I works when I run it on my PC but now that I have
> put it on a server I get an API message. One says the web site needs a
> different Google Maps API key and when I put in the key I get Google has
> disableed use of the Maps API...The key is no a valid Google API Key. I
> have copy and pasted it directly from my API key in the API control panel.
>
> Here is the code I am using to "Display" the map. The actual long/lat
> feature is working, but the displaying map is what is causing this problem

You are using the deprecated Google Maps API v2, any new development
should be done in the Google Maps API v3, which has the added
advantage of not requiring a key (although an API console key is
recommended for tracking usage).

I would suggest moving to v3.

Your issue is likely due to the fact that you don't have a key in your
code (or if you do it is wrong).  The v2 API allowed development on
your local computer without a key (or with an invalid key), but to
deploy on the web, a key is required.

  -- Larry

>
> <!DOCTYPE>
>
> <html>
> <head>
> <title>Geo data</title>
>
> <script src="http://maps.google.com/maps?file=api&v=2&sensor=true";
> type="text/javascript"></script>
> <script src="http://www.google.com/jsapi"; type="text/javascript"></script>
> <script language="JavaScript" 
> src="http://j.maxmind.com/app/geoip.js";></script>
> <script>
> google.load("jquery", "1.4.4");
> </script>
> </head>
> <body>
>
> <script type="text/javascript">
> $(document).ready(function(){
> if(google.loader.ClientLocation) {
> // Google has found you
>
> visitor_lat = google.loader.ClientLocation.latitude;
> visitor_lon = google.loader.ClientLocation.longitude;
> visitor_city = google.loader.ClientLocation.address.city;
> visitor_region = google.loader.ClientLocation.address.region;
> visitor_country = google.loader.ClientLocation.address.country;
>
> visitor_countrycode = google.loader.ClientLocation.address.country_code;
> $("#user_method").html("Google Geo");
> $("#user_latlong").html(visitor_lat + " / " + visitor_lon);
> $("#user_town").html(visitor_city); $("#user_county").html(visitor_region);
> $("#user_country").html(visitor_country + " (" + visitor_countrycode + ")");
>  function success_handler(position) {
>         /* Get the location data */
>         latitude = position.coords.latitude;
>         longitude = position.coords.longitude;
>         accuracy = position.coords.accuracy;
>
>         $.cookie("posLat", latitude);
>         $.cookie("posLon", "failed");
>         $.cookie("posAccuracy", accuracy);
>
> }
> }
>
> else {
> // Google couldnt find you, Maxmind could
> visitor_lat = geoip_latitude();
> visitor_lon = geoip_longitude();
> visitor_city = geoip_city();
> visitor_region_code = geoip_region();
> visitor_region = geoip_region_name();
> visitor_country = geoip_country_name();
> visitor_countrycode = geoip_country_code();
> visitor_postcode = geoip_postal_code();
> $("#user_method").html("MaxMind");
> $("#user_latlong").html(visitor_lat + " / " + visitor_lon);
> $("#user_postcode").html(visitor_postcode);
> $("#user_town").html(visitor_city); $("#user_county").html(visitor_region +
> " ("+visitor_region_code+")");
> $("#user_country").html(visitor_country + " (" + visitor_countrycode + ")");
>  function success_handler(position) {
>         /* Get the location data */
>         latitude = position.coords.latitude;
>         longitude = position.coords.longitude;
>         accuracy = position.coords.accuracy;
>
>         $.cookie("posLat", latitude);
>         $.cookie("posLon", "failed");
>         $.cookie("posAccuracy", accuracy);
>
> }
> }
>
> if (GBrowserIsCompatible()) {
> var map = new GMap2(document.getElementById("map_canvas"));
> var latlng = new GLatLng(visitor_lat, visitor_lon);
> map.setCenter(latlng, 13);
> map.addOverlay(new GMarker(latlng));
> var center = latlng;
> var radius = 0.65;
> //convert kilometers to miles-diameter
> var radius = radius*1.609344;
> var latOffset = 0.01;
> var lonOffset = 0.01;
> var latConv = center.distanceFrom(new GLatLng(center.lat()+0.1,
> center.lng()))/100;
> var lngConv = center.distanceFrom(new GLatLng(center.lat(),
> center.lng()+0.1))/100;
> // nodes = number of points to create circle polygon
> var nodes = 40;
> //Loop
> var points = [];
> var step = parseInt(360/nodes)||10;
> for(var i=0; i<=360; i+=step) {
> var pint = new GLatLng(center.lat() + (radius/latConv * Math.cos(i *
> Math.PI/180)), center.lng() + (radius/lngConv * Math.sin(i * Math.PI/
> 180)));
> // push pints into points array
> points.push(pint);}
>
> var polygon = new GPolygon(points, "#f33f00", 1, 1, "#ff0000", 0.1);
> map.addOverlay(polygon);
>
> }
> });
>
> </script>
>
> </body>
> <div id="geoData">
> <table style="width: 200px;" cellspacing="0" cellpadding="0">
> <tbody>
> <tr>
> <td colspan="2">
>
> <div id="map_canvas" style="margin:10px; border:1px solid #007; width:
> 200px; height: 160px;">Enable Javascript to view this map</div></td>
>
> </tr>
>
> </tbody>
> </table>
>
> </div>
> </html>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" 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-maps-api?hl=en.

Reply via email to