forked from howardchn/location-to-phone-number
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefault.aspx
91 lines (79 loc) · 3.38 KB
/
Default.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"
Theme="default" %>
<!DOCTYPE HTML>
<html>
<head runat="server">
<title>Mobile Phone Locator</title>
</head>
<body onload="initialize();">
<form id="form1" runat="server">
<div id="root">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
<div id="map"></div>
<div class="interaction-panel">
<input type="text" id="iptCode" maxlength="11" class="code" placeholder="Phone number" />
<input type="button" value="Locate" onclick="lookup()" class="btsub" />
<input type="checkbox" checked="checked" id="lock" />
<span style="font-size: 10px; font-family: Verdana;">Lock current zoom.</span>
</div>
</div>
</form>
<script src="http://maps.google.com/maps?file=api&v=2.x&key=AIzaSyD1ALJ7CXfNuzSWVwP1B0Sl_FqGxNWLarU" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var markers = [];
var markerClusterer = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById('map'));
map.setCenter(new GLatLng(35, 106.38), 4);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
var icon = new GIcon(G_DEFAULT_ICON);
icon.image = "http://chart.apis.google.com/chart?cht=mm&chs=24x32&chco=FFFFFF,008CFF,000000&ext=.png";
}
}
var marker = null;
var lookup = function () {
var code = $get("iptCode").value;
PageMethods.GetMobileCodeInfo(code, lookupCompleted);
}
var lookupCompleted = function (text) {
var index = text.indexOf(':');
if (index != -1) {
var code = text.substring(0, index);
var description = text.substring(index + 1, text.length);
var locations = description.split(' ');
var location = locations[1];
var message = '<span class="highlight">' + code + '</span><br/><br/>';
message += '<span class="nortxt">'
for (var i = 0; i < locations.length; i++) {
message += locations[i];
if (i != locations.length - 1)
message += ',';
}
message += '</span>'
var geocoder = new GClientGeocoder();
geocoder.getLatLng(location, function (point) {
if (!point) {
alert(location + " not found.");
} else {
if ($get('lock').checked) {
map.setCenter(point, 4);
} else {
map.setCenter(point, 8);
}
if (marker != null) {
map.removeOverlay(marker);
}
marker = new GMarker(point);
map.addOverlay(marker);
marker.openInfoWindowHtml(message);
}
});
}
}
</script>
</body>
</html>