-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.html
87 lines (83 loc) · 2.55 KB
/
map.html
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
<script src='http://www.google.com/jsapi' type='text/javascript'></script>
<script type="text/javascript">
//
// NOTE: This example uses Google AJAX API Loader to load the Google Maps API
// To use the Google AJAX API Loader, add a script tag with src=http://www.google.com/jsapi?key=YOUR-GOOGLE-AJAX-API-KEY
// All Google Maps API classes, methods and properties are referenced via google.maps.* namespace
//
google.load( 'maps', '2' );
google.setOnLoadCallback(
function( ) {
google.maps.Event.addDomListener( window, 'unload', google.maps.Unload );
}
);
</script>
<script type="text/javascript">
var map;
var geocoder;
function map_initialize( )
{
if ( google.maps.BrowserIsCompatible( ) )
{
//
// initialize map
//
map = new google.maps.Map2( document.getElementById( 'map-view' ) );
map.addControl( new google.maps.LargeMapControl3D( ) );
map.addControl( new google.maps.MenuMapTypeControl( ) );
map.setCenter( new google.maps.LatLng( 6.9167, 79.8333 ), 8 );
//
// initialize marker
//
var marker = new google.maps.Marker( map.getCenter( ), { draggable: true } );
google.maps.Event.addListener( marker, 'dragend', function( p )
{
map.panTo( p );
}
);
map.addOverlay( marker );
//
// initialize geocoder
//
geocoder = new google.maps.ClientGeocoder( );
//
// initialize divs
//
pWindow = opener.window;
pWindow.document.getElementById( 'txtLat' ).value = map.getCenter( ).lat( ).toFixed( 6 );
pWindow.document.getElementById( 'txtLong' ).value = map.getCenter( ).lng( ).toFixed( 6 );
//
// hook map movement event(s)
//
google.maps.Event.addListener( map, 'moveend', function( )
{
marker.setLatLng( map.getCenter( ) );
pWindow.document.getElementById( 'txtLat' ).value = map.getCenter( ).lat( ).toFixed( 6 );
pWindow.document.getElementById( 'txtLong' ).value = map.getCenter( ).lng( ).toFixed( 6 );
}
);
}
}
function map_geocode( address )
{
if ( map && geocoder )
{
geocoder.getLatLng(
address,
function( p )
{
if ( p )
{
map.panTo( p );
}
else
{
alert( 'Sorry, the geocoder failed to locate the specified address :-(' );
}
}
);
}
}
google.setOnLoadCallback( map_initialize );
</script>
<div id="map-view" style="height:500px;width:900px;"></div>