Files
Oliver Dunk 5bf419b385 Reorganize directory structure (#825)
* Remove docs folder.

This was a redirect from a GitHub pages site that does not appear
to be in use.

* Rename api folder to api-samples.

* Move examples to functional-samples folder.

* Move cookbook sample to functional-samples.

* Move tutorials to functional-samples folder.

* Move mv2 and apps folders to _archive.

* Rename tools folder to .repo.

* Move reference folder to functional-samples.

* Update README.

Update README with new relative links for reorg.

* Update README.md

Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com>

---------

Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com>
2023-02-03 10:58:04 -06:00

46 lines
1.4 KiB
JavaScript

// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict'
const kMaps_key = 'AIzaSyBa5aieunaIp3Obco-dNVYMdbnTZGAVkKQ';
function gclient_geocode(address) {
let url = 'https://maps.googleapis.com/maps/api/geocode/json?address=' +
encodeURIComponent(address) + '&sensor=false';
let request = new XMLHttpRequest();
request.open('GET', url, true);
console.log(url);
request.onreadystatechange = function (e) {
console.log(request, e);
if (request.readyState == 4) {
if (request.status == 200) {
let json = JSON.parse(request.responseText);
let latlng = json.results[0].geometry.location;
latlng = latlng.lat + ',' + latlng.lng;
let src = 'https://maps.googleapis.com/maps/api/staticmap?center=' +
latlng + '&markers=' + latlng + '&zoom=14' +
'&size=512x512&sensor=false&key=' + kMaps_key;
let map = document.getElementById('map');
map.src = src;
map.addEventListener('click', function () {
window.close();
});
} else {
console.log('Unable to resolve address into lat/lng');
}
}
};
request.send(null);
}
function map() {
chrome.storage.local.get(['address'], function(value){
gclient_geocode(value.address);
})
}
window.onload = map;