/** * @see MapsBaseMap::addSpecificMapHTML() * */ public function addSpecificMapHTML(Parser $parser) { global $egValidatorErrorLevel; MapsGoogleMaps::addOverlayOutput($this->output, $this->mapName, $this->overlays, $this->controls); if ($egValidatorErrorLevel >= Validator_ERRORS_WARN) { $couldNotGeocodeMsg = Xml::escapeJsString(wfMsg('ukgeocoding_couldNotGeocode')); $showErrorJs = "document.getElementById( '{$this->mapName}_errors' ).innerHTML = '{$couldNotGeocodeMsg}';"; } else { $showErrorJs = ''; } $this->output .= Html::element('div', array('id' => $this->mapName, 'style' => "width: {$this->width}; height: {$this->height}; background-color: #cccccc;"), wfMsg('maps-loading-map')) . "<div id='{$this->mapName}_errors'></div>"; $parser->getOutput()->addHeadItem(Html::inlineScript(<<<EOT \$(function() { \tvar map = initializeGoogleMap('{$this->mapName}', \t\t{ \t\tlat: 0, \t\tlon: 0, \t\tzoom: {$this->zoom}, \t\ttype: {$this->type}, \t\ttypes: [{$this->types}], \t\tcontrols: [{$this->controls}], \t\tscrollWheelZoom: {$this->autozoom} \t\t}, \t\t[] \t); \tvar localSearch = new GlocalSearch(); \tfunction usePointFromPostcode( marker, callbackFunction ) { \t\tlocalSearch.setSearchCompleteCallback( null, \t\t\tfunction() { \t\t\t\tif ( localSearch.results[0] ) { \t\t\t\t\tcallbackFunction(new GLatLng(localSearch.results[0].lat, localSearch.results[0].lng), marker); \t\t\t\t} else { \t\t\t\t\t{$showErrorJs} \t\t\t\t} \t\t\t} \t\t); \t\tlocalSearch.execute(marker.location + ", UK"); \t} \tfunction updateGoogleMap(point, marker) { \t\tmap.addOverlay(createGMarker(point, marker.title, marker.label, marker.icon)); \t\tbounds.extend(point); \t\tmap.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); \t\tif({$this->zoom}!=null) map.setZoom({$this->zoom}); \t} \tvar markers = [{$this->markerString}]; \tvar bounds = new GLatLngBounds(); \tfor(i in markers) { \t\tusePointFromPostcode(markers[i], updateGoogleMap); \t} });\t\t\t\t EOT )); }
/** * @see MapsBaseMap::addSpecificMapHTML() * */ public function addSpecificMapHTML( Parser $parser ) { global $egValidatorErrorLevel; MapsGoogleMaps::addOverlayOutput( $this->output, $this->mapName, $this->overlays, $this->controls ); if ( $egValidatorErrorLevel >= Validator_ERRORS_WARN ) { $couldNotGeocodeMsg = Xml::escapeJsString( wfMsg( 'ukgeocoding_couldNotGeocode' ) ); $showErrorJs = "document.getElementById( '{$this->mapName}_errors' ).innerHTML = '$couldNotGeocodeMsg';"; } else { $showErrorJs = ''; } $this->output .= Html::element( 'div', array( 'id' => $this->mapName, 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", ), wfMsg( 'maps-loading-map' ) ) . "<div id='{$this->mapName}_errors'></div>"; $parser->getOutput()->addHeadItem( Html::inlineScript( <<<EOT addOnloadHook( function() { var map = initializeGoogleMap('$this->mapName', { lat: 0, lon: 0, zoom: $this->zoom, type: $this->type, types: [$this->types], controls: [$this->controls], scrollWheelZoom: $this->autozoom }, [] ); var localSearch = new GlocalSearch(); function usePointFromPostcode( marker, callbackFunction ) { localSearch.setSearchCompleteCallback( null, function() { if ( localSearch.results[0] ) { callbackFunction(new GLatLng(localSearch.results[0].lat, localSearch.results[0].lng), marker); } else { $showErrorJs } } ); localSearch.execute(marker.location + ", UK"); } function updateGoogleMap(point, marker) { map.addOverlay(createGMarker(point, marker.title, marker.label, marker.icon)); bounds.extend(point); map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds)); if($this->zoom!=null) map.setZoom($this->zoom); } var markers = [$this->markerString]; var bounds = new GLatLngBounds(); for(i in markers) { usePointFromPostcode(markers[i], updateGoogleMap); } }); EOT ) ); }