-
-
Save anonymous/97094 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Socialight command. */ | |
function getData(kmlUrl) { | |
return "var tURL = '" + kmlUrl + "'; " + <r><![CDATA[ | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | |
<head> | |
<title>Sicialight KML Map</title> | |
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> | |
<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAxf7TtjMwMjT9Hs4imJPyFBR26EVGtzYpOEGW6W2HpjrJiRKlLRTObx8hZ3b0zk-i0Neo8pqpkqDZQA" type="text/javascript"> | |
</script> | |
<script type="text/javascript"> | |
var map; | |
var geoXml; | |
function initialize() { | |
if (GBrowserIsCompatible()) { | |
geoXml = new GGeoXml(tURL); | |
map = new GMap2(document.getElementById("map_canvas")); | |
map.setCenter(new GLatLng(41.875696,-87.624207), 11); | |
map.addControl(new GLargeMapControl()); | |
map.addControl(new GLargeMapControl()); | |
map.addOverlay(geoXml); | |
} | |
} | |
</script> | |
<body onload="initialize()"> | |
<div id="map_canvas" style="width: 640px; height: 480px; float:left; border: 1px solid black;"></div> | |
</body> | |
</html> | |
]]></r>; | |
} | |
CmdUtils.CreateCommand({ | |
name: "socialight", | |
icon: "http://socialight.com/favicon.ico", | |
homepage: "http://socialight.com/", | |
author: { name: "Michele Mostarda", email: "michele.mostarda@gmail.com"}, | |
license: "GPL", | |
description: "Socialight search command.", | |
help: "socialight <address>", | |
takes: {"address": noun_arb_text}, | |
preview: function( pblock, input ) { | |
pblock.innerHTML = "socialight <address>"; | |
}, | |
execute: function(address) { | |
CmdUtils.geocodeAddress( | |
address.html, | |
function(points) { | |
var url = "http://socialight.com/api/layer?appid=9d81d60c7923d62dc715d275e2ec7b65e8deba1c&latitude=${lat}&longitude=${lon}&limit=10&format=kml"; | |
var localizedUrl = CmdUtils.renderTemplate(url, {"lat": points[0].lat , "lon" : points[0].lon }); | |
Utils.openUrlInBrowser(localizedUrl); | |
Utils.reportWarning("getData(localizedUrl): " + getData(localizedUrl)); | |
var win = window.open('chrome:',"KML Map","height=480,width=640,top=10,left=10,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no"); | |
win.document.write( getData(localizedUrl) ); | |
} | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment