7
|
1
|
|
2
|
|
3 function displayGeoname(geoname){
|
|
4
|
|
5 //var rectangle;
|
|
6
|
|
7 var myOptions = {
|
|
8 zoom: 6,
|
|
9 //center: coachella,
|
|
10 mapTypeId: google.maps.MapTypeId.TERRAIN
|
|
11 };
|
|
12 //mapTypeId: google.maps.MapTypeId.SATELLITE
|
|
13 //mapTypeId: google.maps.MapTypeId.TERRAIN
|
|
14
|
|
15 var map = new google.maps.Map(document.getElementById("geoMap"), myOptions);
|
|
16 var canvas = document.getElementById("geoMap");
|
|
17 canvas.style.width= '700px';
|
|
18 canvas.style.height= '450px';
|
|
19
|
|
20 if(geoname){
|
|
21 var latlng = new google.maps.LatLng(geoname.lat, geoname.lng);
|
|
22 map.setCenter(latlng);
|
|
23 map.setZoom(8);
|
|
24 createMarker(map, latlng, geoname);
|
|
25 }
|
|
26 }
|
|
27
|
|
28 function createMarker(map, point, geoname) {
|
|
29
|
|
30 var infowindow = new google.maps.InfoWindow();
|
|
31
|
|
32 var pinImage = new google.maps.MarkerImage(
|
|
33 "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2%7CFE7569",
|
|
34 new google.maps.Size(21, 34),
|
|
35 new google.maps.Point(0,0),
|
|
36 new google.maps.Point(10, 34));
|
|
37
|
|
38 var marker = new google.maps.Marker({
|
|
39 position: point,
|
|
40 map: map,
|
|
41 icon: pinImage
|
|
42 });
|
|
43
|
|
44 google.maps.event.addListener(marker, 'click',
|
|
45 function(){
|
|
46 var infoHtml = "";
|
|
47 if(geoname.geonameId){
|
|
48 infoHtml+= "Id: <b>" + geoname.geonameId + "</b><br>";
|
|
49 }
|
|
50 if(geoname.name){
|
|
51 infoHtml+= "Name: <b>" + geoname.name + "</b><br>";
|
|
52 }
|
|
53 if(geoname.toponymName){
|
|
54 infoHtml+= "Toponym name: <b>" + geoname.toponymName + "</b><br>";
|
|
55 }
|
|
56 if(geoname.countryName){
|
|
57 infoHtml+= "Country: <b>" + geoname.countryName + "</b><br>";
|
|
58 }
|
|
59 if(geoname.class.description){
|
|
60 infoHtml+= "Description: <b>" + geoname.class.description + "</b><br>";
|
|
61 }
|
|
62 infowindow.setContent(infoHtml);
|
|
63 infowindow.open(map, marker);
|
|
64 }
|
|
65 );
|
|
66
|
|
67 //return marker;
|
|
68 }
|
|
69 /*
|
|
70 function getGeonameById(id){
|
|
71 var url =
|
|
72 "https://openmind-ismi-dev.mpiwg-berlin.mpg.de/geonames/service?" +
|
|
73 "method=getGeoname&mode=json&geonameId="+
|
|
74 id;
|
|
75
|
|
76 var jsonResponse = httpGet(url);
|
|
77 return jsonResponse;
|
|
78 }
|
|
79
|
|
80 function httpGet(theUrl){
|
|
81 var xmlHttp = null;
|
|
82
|
|
83 xmlHttp = new XMLHttpRequest();
|
|
84 xmlHttp.open( "GET", theUrl, false );
|
|
85
|
|
86 xmlHttp.addEventListener("progress", updateProgress, false);
|
|
87 xmlHttp.addEventListener("load", transferComplete, false);
|
|
88 xmlHttp.addEventListener("error", transferFailed, false);
|
|
89 xmlHttp.addEventListener("abort", transferCanceled, false);
|
|
90
|
|
91
|
|
92 xmlHttp.send( );
|
|
93 var txt = xmlHttp.responseText;
|
|
94 return txt;
|
|
95 }
|
|
96
|
|
97 //progress on transfers from the server to the client (downloads)
|
|
98 function updateProgress(evt) {
|
|
99 if (evt.lengthComputable) {
|
|
100 var percentComplete = evt.loaded / evt.total;
|
|
101
|
|
102 } else {
|
|
103 // Unable to compute progress information since the total size is unknown
|
|
104 }
|
|
105 }
|
|
106
|
|
107 function transferComplete(evt) {
|
|
108 alert("The transfer is complete.");
|
|
109 }
|
|
110
|
|
111 function transferFailed(evt) {
|
|
112 alert("An error occurred while transferring the file.");
|
|
113 }
|
|
114
|
|
115 function transferCanceled(evt) {
|
|
116 alert("The transfer has been canceled by the user.");
|
|
117 }
|
|
118 */ |