Pebbles

My thoughts, my expressions.

Google Maps – making your map accessible to api without api key

Days back I was playing around with Google’s maps and I found it quite frustrating that the maps I created with http://maps.google.com/maps/mm is not accessible by APIs unless I authenticate by signing in to my Google account. I was getting a ‘map not api visible’ error. For those who are having similar situation, here is the solution. Use any api (java, php, python or even javascript) to set your map’s  ‘api_visible’ property to true!

<script>
function login(){
token = google.accounts.user.login('http://maps.google.com/maps/feeds');
if(token) updateMap();
}

function updateMap() {
//mapUrl is the url to your map - http://maps.google.com/maps/feeds/maps/userID/full/mapID
service.getMapEntry(mapUrl, function(entryRoot) {
var entry = entryRoot.entry;
entry.addCustomProperty({name:'api_visible', value:'1'});
entry.updateEntry(
function(ent){alert('Updated!');},
function(e){alert('Upadte err...' + e);});},
function(e){alert("Err..." + e);}
);
}
</script>
<input onclick="login();" type="button" value="Authenticate!" />
<input onclick="updateMap();" type="button" value="Update!" />

Happy mapping!

Advertisement

5 Responses to Google Maps – making your map accessible to api without api key

  1. tony July 5, 2010 at 12:51 pm

    please help.
    do i need to run this script each time i use the map,cause i tried and got the same error ‘map not api visible’

    if you can provide a complete code i will be thankful
    thanks in adavnce.

  2. tony July 6, 2010 at 11:42 am

    The error is gone,but the response doesn’t contain any search results (entry field).
    any suggestions?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.