1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w";
7 function gclient_geocode(address) {
8 var url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' +
9 encodeURIComponent(address) + '&sensor=false';
10 var request = new XMLHttpRequest();
12 request.open('GET', url, true);
14 request.onreadystatechange = function (e) {
15 console.log(request, e);
16 if (request.readyState == 4) {
17 if (request.status == 200) {
18 var json = JSON.parse(request.responseText);
19 var latlng = json.results[0].geometry.location;
20 latlng = latlng.lat + ',' + latlng.lng;
22 var src = "https://maps.google.com/staticmap?center=" + latlng +
23 "&markers=" + latlng + "&zoom=14" +
24 "&size=512x512&sensor=false&key=" + maps_key;
25 var map = document.getElementById("map");
28 map.addEventListener('click', function () {
32 console.log('Unable to resolve address into lat/lng');
40 var address = chrome.extension.getBackgroundPage().selectedAddress;
42 gclient_geocode(address);