Changeset 12698 for extensions/rv_gmaps/trunk/template/map.tpl
- Timestamp:
- Dec 6, 2011, 5:42:24 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/template/map.tpl
r12367 r12698 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">1 <!DOCTYPE html> 2 2 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"> 3 3 <head> 4 4 <meta http-equiv="content-type" content="text/html; charset={$CONTENT_ENCODING}" /> 5 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> 5 6 <meta name="robots" content="noindex,nofollow" /> 6 7 <title>{$GALLERY_TITLE}</title> 7 8 8 <script src="http://maps.google .com/maps?file=api&v=2&key={$GMAPS_API_KEY}&hl={$lang_info.code}" type="text/javascript"></script>9 <script src="http://maps.googleapis.com/maps/api/js?sensor=false&language={$lang_info.code}" type="text/javascript"></script> 9 10 10 11 {combine_script id='jquery' load='header' path='http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'} … … 46 47 document._window = window; 47 48 } 48 49 50 function glog(msg) { 51 if (console) 52 { 53 console.debug(msg + " b="+map.getBounds().toUrlValue() + " c="+map.getCenter().toUrlValue() + " z="+map.getZoom() ); 54 } 55 } 56 49 57 function load() 50 58 { 51 if (!GBrowserIsCompatible()) 52 return; 53 54 var mapElement = document.getElementById("map"); 55 map = new google.maps.Map2( mapElement ); 56 57 map.addMapType( G_PHYSICAL_MAP ); 58 map.addControl(new google.maps.LargeMapControl3D()); 59 map.addControl(new google.maps.HierarchicalMapTypeControl()); 60 map.addControl(new google.maps.ScaleControl()); 61 62 pwgPageLinker = new PageLinker(map, "aLinkToThisPage" ); 63 if ( !map.isLoaded() ) 59 var mapOptions = { 60 mapTypeId: google.maps.MapTypeId.ROADMAP, 61 overviewMapControl: true 62 } 63 64 if (1/*!PageLinker.url2Map(mapOptions)*/) 64 65 { 65 66 {/literal} 66 67 {if isset($initial_bounds)} 67 var bounds = new google.maps.LatLngBounds( new google.maps.LatLng({$initial_bounds.s},{$initial_bounds.w}), new google.maps.LatLng({$initial_bounds.n},{$initial_bounds.e}) ); 68 map.setCenter( bounds.getCenter(), map.getBoundsZoomLevel( bounds ) ); 68 mapOptions.iniBounds = new google.maps.LatLngBounds( new google.maps.LatLng({$initial_bounds.s},{$initial_bounds.w}), new google.maps.LatLng({$initial_bounds.n},{$initial_bounds.e}) ); 69 mapOptions.center = mapOptions.iniBounds.getCenter(); 70 {else} 71 mapOptions.center = new google.maps.LatLng(0,0); 72 mapOptions.zoom = 2; 69 73 {/if} 70 74 {literal} 71 if ( !map.isLoaded() ) 72 map.setCenter( new google.maps.LatLng(0,0), 2 ); 73 } 74 75 try { 76 // the overview must be added after setting map center 77 var ovcontrol = new google.maps.OverviewMapControl(new google.maps.Size(165,165)); 78 map.addControl(ovcontrol); 79 } 80 catch(e){ alert( e.message ); } 81 82 map.enableScrollWheelZoom(); 83 map.enableDoubleClickZoom(); 84 85 var pwgMarkerIcon = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null); 86 87 map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerIcon.iconSize} ); 88 google.maps.Event.addListener(map.pwgDataLoader, "dataloading", function() { 75 } 76 77 map = new google.maps.Map( document.getElementById("map"), mapOptions ); 78 79 if (mapOptions.iniBounds) 80 map.fitBounds(mapOptions.iniBounds); 81 82 if (document.is_debug) 83 { 84 google.maps.event.addListener(map, "idle", function() { glog("idle"); }); 85 google.maps.event.addListener(map, "bounds_changed", function() { glog("bounds_changed");} ); 86 google.maps.event.addListener(map, "center_changed", function() { glog("center_changed");} ); 87 google.maps.event.addListener(map, "maptypeid_changed", function() { glog("maptypeid_changed");} ); 88 google.maps.event.addListener(map, "zoom_changed", function() { glog("zoom_changed");} ); 89 google.maps.event.addListener(map, "drag", function() { glog("drag");} ); 90 } 91 92 pwgPageLinker = new PageLinker(map, "aLinkToThisPage" ); 93 94 var pwgMarkerOptions = (function(){ {/literal}{$MAP_MARKER_ICON_JS}{literal} }).call(null); 95 96 map.pwgDataLoader = new PwgDataLoader(map, {rectangle_of_confusion: pwgMarkerOptions.roc} ); 97 google.maps.event.addListener(map.pwgDataLoader, "dataloading", function() { 89 98 var pre = '<img src="{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/progress_s.gif" width="16" height="16" alt="~" /> '; 90 99 document.getElementById("dataLoadStatus").innerHTML = pre + Localization.get("Loading"); … … 92 101 ); 93 102 94 google.maps. Event.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) {103 google.maps.event.addListener(map.pwgDataLoader, "dataloadfailed", function(responseCode) { 95 104 document.getElementById("dataLoadStatus").innerHTML = Localization.get("Failed") + " "+responseCode; 96 105 } 97 106 ); 98 107 99 map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarker Icon, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } );100 google.maps. Event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) );108 map.pwgDataHandler = new PwgDataHandler(map, {icon: pwgMarkerOptions, show_all_img_src: "{/literal}{$PLUGIN_ROOT_URL}{literal}/icons/pic_s.gif" } ); 109 google.maps.event.addListener(map.pwgDataLoader, "dataloaded", pwgBind(map.pwgDataHandler, map.pwgDataHandler.handle) ); 101 110 102 111 map.pwgDataLoader.start( "{/literal}{$U_MAP_DATA}{literal}" ); 103 104 if (document.is_debug)105 {106 google.maps.Event.addListener(map, "moveend", function() { google.maps.Log.write("movend c:"+map.getCenter().toUrlValue());} );107 google.maps.Event.addListener(map, "maptypechanged", function() { google.maps.Log.write("maptypechanged");} );108 google.maps.Event.addListener(map, "infowindowopen", function() { google.maps.Log.write("infowindowopen");} );109 google.maps.Event.addListener(map, "infowindowclose", function() { google.maps.Log.write("infowindowclose");} );110 }111 112 } 112 113 … … 118 119 !map.pwgDataHandler || map.pwgDataHandler.terminate(); 119 120 } 120 GUnload();121 121 } 122 122 … … 125 125 if (!q.length) return false; 126 126 if (!geocoder) 127 geocoder = new google.maps. ClientGeocoder();128 geocoder.ge tLocations(q, function(resp)129 {130 if ( resp && resp.Status)127 geocoder = new google.maps.Geocoder(); 128 geocoder.geocode(q, function(results, status) { 129 document._geoResponse = results; 130 if ( status == google.maps.GeocoderStatus.OK ) 131 131 { 132 document._geoResponse = resp; 133 if (resp.Status.code==200) 134 { 135 var zoom = 2; 136 switch (resp.Placemark[0].AddressDetails.Accuracy) 137 { 138 case 1: zoom=5; break; //country 139 case 2: zoom=7; break; //region 140 case 3: zoom=8; break; //county 141 case 4: zoom=12; break; //town 142 case 5: zoom=13; break; //post code 143 case 6: zoom=14; break; //street 144 case 7: case 8: zoom=16; break; //intersection/exact 145 } 146 map.setCenter( new google.maps.LatLng( resp.Placemark[0].Point.coordinates[1], resp.Placemark[0].Point.coordinates[0] ), zoom); 147 } 148 else 149 alert("This address has not been found\nCode:"+resp.Status.code); 150 } 151 }); 132 map.fitBounds( results[0].geometry.viewport ); 133 } 134 else 135 alert("This address has not been found\nCode: "+status); 136 }); 152 137 return false; 153 138 }
Note: See TracChangeset
for help on using the changeset viewer.