| OLD | NEW |
| 1 <style> |
| 2 #map { |
| 3 display: none; |
| 4 width: 512px; |
| 5 height: 512px; |
| 6 } |
| 7 </style> |
| 1 <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAATfHumD
bW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w&sensor=
false" | 8 <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAATfHumD
bW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr4K0xyVKzUdnnuFl8X9PX0w&sensor=
false" |
| 2 type="text/javascript"></script> | 9 type="text/javascript"></script> |
| 3 <script> | 10 <script> |
| 4 var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr
4K0xyVKzUdnnuFl8X9PX0w"; | 11 var maps_key = "ABQIAAAATfHumDbW3OmRByfquHd3SRTRERdeAiwZ9EeJWta3L_JZVS0bOBRQeZgr
4K0xyVKzUdnnuFl8X9PX0w"; |
| 5 | 12 |
| 13 chrome.toolstrip.onCollapsed.addListener(function() { |
| 14 var map = document.getElementById("map"); |
| 15 map.src = ""; |
| 16 map.style.display = "none"; |
| 17 var button = document.getElementById("button"); |
| 18 button.style.display = "block"; |
| 19 }); |
| 20 |
| 21 function expand(url) { |
| 22 var button = document.getElementById("button"); |
| 23 button.style.display = "none"; |
| 24 var map = document.getElementById("map"); |
| 25 map.src = url; |
| 26 map.style.display = "block"; |
| 27 chrome.toolstrip.expand({height:512}, function() {}); |
| 28 } |
| 29 |
| 30 function collapse() { |
| 31 chrome.toolstrip.collapse({}, function() {}); |
| 32 } |
| 33 |
| 6 function gclient_geocode(address) { | 34 function gclient_geocode(address) { |
| 7 var geocoder = new GClientGeocoder(); | 35 var geocoder = new GClientGeocoder(); |
| 8 geocoder.getLatLng(address, function(point) { | 36 geocoder.getLatLng(address, function(point) { |
| 9 if (!point) { | 37 if (!point) { |
| 10 console.log(address + " not found"); | 38 console.log(address + " not found"); |
| 11 } else { | 39 } else { |
| 12 var latlng = point.toUrlValue(); | 40 var latlng = point.toUrlValue(); |
| 13 var url = "http://maps.google.com/staticmap?center=" + latlng + | 41 var url = "http://maps.google.com/staticmap?center=" + latlng + |
| 14 "&markers=" + latlng + "&zoom=14" + | 42 "&markers=" + latlng + "&zoom=14" + |
| 15 "&size=512x512&sensor=false&key=" + maps_key; | 43 "&size=512x512&sensor=false&key=" + maps_key; |
| 16 document.body.style.width = "512px"; | 44 expand(url); |
| 17 setTimeout(chrome.toolstrip.expand, 100, {height:512, url:url}); | |
| 18 } | 45 } |
| 19 }); | 46 }); |
| 20 } | 47 } |
| 21 | 48 |
| 22 function map() { | 49 function map() { |
| 23 chrome.tabs.getSelected(null, function(tab) { | 50 chrome.tabs.getSelected(null, function(tab) { |
| 24 var port = chrome.tabs.connect(tab.id); | 51 var port = chrome.tabs.connect(tab.id); |
| 25 if (!port) { | 52 if (!port) { |
| 26 console.log("no port"); | 53 console.log("no port"); |
| 27 } else { | 54 } else { |
| 28 port.onMessage.addListener(function(data) { | 55 port.onMessage.addListener(function(data) { |
| 29 var address = data.values[0]; | 56 var address = data.values[0]; |
| 30 gclient_geocode(address); | 57 gclient_geocode(address); |
| 31 }); | 58 }); |
| 32 port.postMessage({message: "hello tab: " + tab.id}); | 59 port.postMessage({message: "hello tab: " + tab.id}); |
| 33 } | 60 } |
| 34 }); | 61 }); |
| 35 }; | 62 }; |
| 36 </script> | 63 </script> |
| 37 <div class="toolstrip-button" onclick="map()"> | 64 <div id="button" class="toolstrip-button" onclick="map()"> |
| 38 <span>Mappy</span> | 65 <span>Mappy</span> |
| 39 </div> | 66 </div> |
| 67 <img id="map" onclick="collapse()"> |
| OLD | NEW |