1/* Code based on Google Map APIv3 Tutorials */ 2 3 4var gmapdata= new Array(); 5var gmapmarker = new Array(); 6 7function if_gmap_init(id, form_id) 8{ 9 if(document.getElementById(id+"_element"+form_id)){ 10 map=document.getElementById(id+"_element"+form_id); 11 var def_zoomval = parseInt(map.getAttribute("zoom")); 12 var def_longval = map.getAttribute("center_x"); 13 var def_latval = map.getAttribute("center_y"); 14 15 var curpoint = new google.maps.LatLng(def_latval,def_longval); 16 17 gmapdata[id] = new google.maps.Map(document.getElementById(id+"_element"+form_id), { 18 center: curpoint, 19 zoom: def_zoomval, 20 mapTypeId: 'roadmap' 21 }); 22 23 gmapmarker[id] = new Array(); 24 25 return false; 26 } 27 else 28 { 29 draggab=false; 30map=document.getElementById(id); 31var def_zoomval = parseInt(map.getAttribute("zoom")); 32var def_longval = map.getAttribute("long"); 33var def_latval = map.getAttribute("lat"); 34 35 var curpoint = new google.maps.LatLng(def_latval,def_longval); 36 37 gmapdata = new google.maps.Map(document.getElementById(id), { 38 center: curpoint, 39 zoom: def_zoomval, 40 mapTypeId: 'roadmap' 41 }); 42 43 geocoder = new google.maps.Geocoder(); 44 45 46 gmapmarker = new google.maps.Marker({ 47 map: gmapdata, 48 position: curpoint, 49 draggable: draggab 50 }); 51 gmapmarker.setDraggable(draggab); 52 infoW = new google.maps.InfoWindow; 53 54 google.maps.event.addListener(gmapdata, 'mouseover', function(event) 55 { 56 if(!document.getElementById("longval")) 57 gmapmarker.draggable=false; 58 }); 59 60 google.maps.event.addListener(gmapdata, 'click', function(event) { 61 if(document.getElementById("longval")) 62 { 63 document.getElementById("longval").value = event.latLng.lng().toFixed(6); 64 document.getElementById("latval").value = event.latLng.lat().toFixed(6); 65 gmapmarker.setPosition(event.latLng); 66 if_gmap_updateMap(); 67 68 geocoder.geocode({'latLng': gmapmarker.getPosition()}, function(results, status) 69 { 70 if (status == google.maps.GeocoderStatus.OK) 71 { 72 if (results[0]) 73 { 74 75 if(document.getElementById("addrval")) document.getElementById("addrval").value = results[0].formatted_address; 76 } 77 } 78 }); 79 } 80 81 }); 82 83 google.maps.event.addListener(gmapmarker, 'drag', function() { 84 if(document.getElementById("longval")) 85 { 86 geocoder.geocode({'latLng': gmapmarker.getPosition()}, function(results, status) 87 { 88 if (status == google.maps.GeocoderStatus.OK) 89 { 90 if (results[0]) 91 { 92 93 if(document.getElementById("addrval")) document.getElementById("addrval").value = results[0].formatted_address; 94 } 95 } 96 97 }); 98 99 if_gmap_updateMap(); 100 document.getElementById("latval").value = gmapmarker.getPosition().lat().toFixed(6); 101 document.getElementById("longval").value = gmapmarker.getPosition().lng().toFixed(6); 102 } 103 }); 104 google.maps.event.addListener(gmapmarker, 'click', function() { 105 infoW.setContent('<div style="overflow: hidden;">'+document.getElementById(id).getAttribute('info')+"</div>"); 106 var infoWOpt = { 107 maxWidth: "300" 108 }; 109 infoW.setOptions(infoWOpt); 110 infoW.open(this.getMap(), this); 111 }); 112 113if(document.getElementById("longval")) 114{ 115 document.getElementById("longval").value = def_longval; 116 document.getElementById("latval").value = def_latval; 117 118 geocoder.geocode({'latLng': gmapmarker.getPosition()}, function(results, status) { 119 if (status == google.maps.GeocoderStatus.OK) { 120 if (results[0]) { 121 122 if(document.getElementById("addrval")) document.getElementById("addrval").value = results[0].formatted_address; 123 } 124 } 125 }); 126 127} 128 129 130 131 132 return false;
133 134 } 135} // end of if_gmap_init 136 137 138function add_marker_on_map(id, i, w_long, w_lat, w_info, form_id, dragb) 139{ 140 var marker_point = new google.maps.LatLng(w_lat, w_long); 141 142 143 144 gmapmarker[id][i] = new google.maps.Marker({ 145 map: gmapdata[id], 146 position: marker_point, 147 draggable: dragb 148 }); 149 150 gmapmarker[id][i].setDraggable(dragb); 151 152 if(dragb) 153 { 154 google.maps.event.addListener(gmapmarker[id][i], 'drag', function() 155 { 156 document.getElementById(id+"_lat"+form_id).value = gmapmarker[id][i].getPosition().lat().toFixed(6); 157 document.getElementById(id+"_long"+form_id).value = gmapmarker[id][i].getPosition().lng().toFixed(6); 158 }); 159 } 160 161 infoW = new google.maps.InfoWindow; 162 163 google.maps.event.addListener(gmapmarker[id][i], 'click', function() 164 { 165 infoW.setContent('<div style="overflow: hidden;">'+document.getElementById(id+"_element"+form_id).getAttribute('info'+i)+"</div>"); 166 var infoWOpt = { 167 maxWidth: "300" 168 }; 169 infoW.setOptions(infoWOpt); 170 infoW.open(this.getMap(), this); 171 }); 172 173 return false; 174 175 176} // end of if_gmap_init 177
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.