function on_every_time() { $protocol = HTTPS_AVAILABLE && on_secure_page() ? 'https' : 'http'; $campusTemplateID = defined('GOOGLE_MAPS_CAMPUS_TEMPLATE_ID') ? GOOGLE_MAPS_CAMPUS_TEMPLATE_ID : ''; parent::on_every_time(); echo '<link href="' . $protocol . '://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />' . "\n"; echo '<style type="text/css"> #map_canvas { width: 600px; height: 400px; } #googlemapprimarypushpinlatitudeRow {display: none;} /* hack to avoid changing hidden input field */ #googlemapprimarypushpinlongitudeRow {display: none;} #googlemapdestinationlatitudeRow {display: none;} /* hack to avoid changing hidden input field */ #googlemapdestinationlongitudeRow {display: none;} </style>' . "\n"; echo ' <script type="text/javascript" src="' . $protocol . '://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script type="text/javascript" src="' . $protocol . '://google-maps-utility-library-v3.googlecode.com/svn/trunk/styledmarker/src/StyledMarker.js"></script> <script type="text/javascript"> google.maps.visualRefresh = true; function initialize() { var latLng = new google.maps.LatLng(' . $this->get_value('google_map_latitude') . ',' . $this->get_value('google_map_longitude') . '); var myOptions = { zoom:' . $this->get_value('google_map_zoom_level') . ', center: latLng, mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControl: false, streetViewControl: false }; var map = new google.maps.Map(document.getElementById(\'map_canvas\'), myOptions); var arrayOfMsids = ["' . preg_replace("|\\s|", '","', $this->get_value('google_map_msid')) . '"]; if (document.disco_form.google_map_show_campus_template.options[document.disco_form.google_map_show_campus_template.options.selectedIndex].value == "yes" && "' . $campusTemplateID . '" != \'\') { arrayOfMsids.splice(0, 0, "' . $campusTemplateID . '"); } var nyLayer = []; setLayers(arrayOfMsids, nyLayer, map); var primaryPushpin = new google.maps.Marker({position: new google.maps.LatLng(' . $this->get_value('google_map_primary_pushpin_latitude') . ', ' . $this->get_value('google_map_primary_pushpin_longitude') . '),map: map,draggable:true}); //var primaryPushpin = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.MARKER,{color:"B0C4DE"}),position:new google.maps.LatLng(' . $this->get_value('google_map_primary_pushpin_latitude') . ', ' . $this->get_value('google_map_primary_pushpin_longitude') . '),map:map,draggable:true}); if (document.getElementById("radio_google_map_show_primary_pushpin_0").checked) { showMarker(primaryPushpin, 0); } else { showMarker(primaryPushpin, 1); } var destMarker = new StyledMarker({styleIcon:new StyledIcon(StyledIconTypes.BUBBLE,{color:"#cccccc",text:"To"}),position:new google.maps.LatLng(' . $this->get_value('google_map_destination_latitude') . ', ' . $this->get_value('google_map_destination_longitude') . '),map:map,draggable:true}); if (document.getElementById("radio_google_map_show_directions_0").checked) { showMarker(destMarker, 0); } else { showMarker(destMarker, 1); } google.maps.event.addListener(map, \'dragend\', function(e) { updateMarkerPosition(map.getCenter()); }); google.maps.event.addListener(map, \'zoom_changed\', function(e) { document.disco_form.google_map_zoom_level.value = map.getZoom(); }); google.maps.event.addDomListener(document.disco_form.google_map_zoom_level, \'change\', function(e) { map.setZoom(parseInt(document.disco_form.google_map_zoom_level.value)); }); google.maps.event.addDomListener(document.disco_form.google_map_latitude, \'change\', function(e) { var cntr = new google.maps.LatLng(Math.min(85.0511, Math.max(-85.0511, parseFloat(document.disco_form.google_map_latitude.value))), parseFloat(document.disco_form.google_map_longitude.value)); map.setCenter(cntr); updateMarkerPosition(map.getCenter()); }); google.maps.event.addDomListener(document.disco_form.google_map_longitude, \'change\', function(e) { var cntr = new google.maps.LatLng(parseFloat(document.disco_form.google_map_latitude.value), parseFloat(document.disco_form.google_map_longitude.value)); map.setCenter(cntr); updateMarkerPosition(map.getCenter()); }); google.maps.event.addDomListener(document.getElementById("radio_google_map_show_primary_pushpin_0"), \'change\', function(e) { showMarker(primaryPushpin, 0); }); google.maps.event.addDomListener(document.getElementById("radio_google_map_show_primary_pushpin_1"), \'change\', function(e) { showMarker(primaryPushpin, 1); }); google.maps.event.addDomListener(primaryPushpin, \'dragend\', function(e) { var dragEnd = e.latLng; document.disco_form.google_map_primary_pushpin_latitude.value = dragEnd.lat(); document.disco_form.google_map_primary_pushpin_longitude.value = dragEnd.lng(); }); google.maps.event.addDomListener(document.getElementById("radio_google_map_show_directions_0"), \'change\', function(e) { showMarker(destMarker, 0); }); google.maps.event.addDomListener(document.getElementById("radio_google_map_show_directions_1"), \'change\', function(e) { showMarker(destMarker, 1); }); google.maps.event.addDomListener(destMarker, \'dragend\', function(e) { var dragEnd = e.latLng; document.disco_form.google_map_destination_latitude.value = dragEnd.lat(); document.disco_form.google_map_destination_longitude.value = dragEnd.lng(); }); google.maps.event.addDomListener(document.disco_form.google_map_show_campus_template, \'change\', function(e) { for (var i = 0; i < arrayOfMsids.length; i++) { nyLayer[i].setMap(null); } arrayOfMsids.splice(0, arrayOfMsids.length); nyLayer.length = 0; arrayOfMsids = document.disco_form.google_map_msid.value.split("\\n"); if (document.disco_form.google_map_show_campus_template.options[document.disco_form.google_map_show_campus_template.options.selectedIndex].value == "yes" && "' . $campusTemplateID . '" != \'\') { arrayOfMsids.splice(0, 0, "' . $campusTemplateID . '"); } setLayers(arrayOfMsids, nyLayer, map) }); google.maps.event.addDomListener(document.disco_form.google_map_msid, \'change\', function(e) { for (var i = 0; i < arrayOfMsids.length; i++) { nyLayer[i].setMap(null); } arrayOfMsids.splice(0, arrayOfMsids.length); nyLayer.length = 0; arrayOfMsids = document.disco_form.google_map_msid.value.split("\\n"); if (document.disco_form.google_map_show_campus_template.options[document.disco_form.google_map_show_campus_template.options.selectedIndex].value == "yes" && "' . $campusTemplateID . '" != \'\') { arrayOfMsids.splice(0, 0, "' . $campusTemplateID . '"); } setLayers(arrayOfMsids, nyLayer, map) }); } function updateMarkerPosition(latLng) { document.disco_form.google_map_latitude.value = latLng.lat(); document.disco_form.google_map_longitude.value = latLng.lng(); } function setLayers(arrayOfMsids, nyLayer, map) { for (var i = 0; i < arrayOfMsids.length; i++) { nyLayer[i] = new google.maps.KmlLayer(\'' . $protocol . '://maps.google.com/maps/ms?msid=\' + arrayOfMsids[i] + \'&msa=0&output=kml\', { suppressInfoWindows: false, map: map, preserveViewport:true }); nyLayer[i].setMap(map); } } function showMarker(marker, show) { if (show == 0) { marker.setVisible(true); } else { marker.setVisible(false); } } google.maps.event.addDomListener(window, \'load\', initialize); </script>' . "\n"; echo '<div id="map_canvas"></div><br/>' . "\n"; }