Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFunctions.js |
— | — | @@ -11,8 +11,8 @@ |
12 | 12 | * This function holds spesific functionallity for the Yahoo! Maps form input of Semantic Maps |
13 | 13 | * TODO: Refactor as much code as possible to non specific functions |
14 | 14 | */ |
15 | | -function makeFormInputYahooMap(mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon, height) { |
16 | | - var map = createYahooMap(document.getElementById(mapName), new YGeoPoint(lat, lon), zoom, type, types, controls, scrollWheelZoom, [getYMarkerData(marker_lat, marker_lon, '', '', '')], height); |
| 15 | +function makeFormInputYahooMap(mapName, locationFieldName, lat, lon, zoom, type, types, controls, scrollWheelZoom, marker_lat, marker_lon) { |
| 16 | + var map = createYahooMap(document.getElementById(mapName), new YGeoPoint(lat, lon), zoom, type, types, controls, scrollWheelZoom, [getYMarkerData(marker_lat, marker_lon, '', '', '')]); |
17 | 17 | |
18 | 18 | // Show a starting marker only if marker coordinates are provided |
19 | 19 | if (marker_lat != null && marker_lon != null) { |
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php |
— | — | @@ -46,12 +46,11 @@ |
47 | 47 | * |
48 | 48 | */ |
49 | 49 | protected function addSpecificMapHTML( Parser $parser ) { |
50 | | - global $wgJsMimeType; |
51 | | - |
| 50 | + // TODO: refactor up like done in maps with display point |
52 | 51 | $markerItems = array(); |
53 | 52 | |
54 | 53 | foreach ( $this->m_locations as $location ) { |
55 | | - // Create a string containing the marker JS |
| 54 | + // Create a string containing the marker JS. |
56 | 55 | list( $lat, $lon, $title, $label, $icon ) = $location; |
57 | 56 | |
58 | 57 | $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')"; |
— | — | @@ -59,18 +58,37 @@ |
60 | 59 | |
61 | 60 | $markersString = implode( ',', $markerItems ); |
62 | 61 | |
63 | | - $this->output .= " |
64 | | - <div id='$this->mapName' style='width: {$this->width}px; height: {$this->height}px;'></div> |
| 62 | + $this->output .= Html::element( |
| 63 | + 'div', |
| 64 | + array( |
| 65 | + 'id' => $this->mapName, |
| 66 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 67 | + ), |
| 68 | + wfMsg('maps-loading-map') |
| 69 | + ); |
65 | 70 | |
66 | | - <script type='$wgJsMimeType'>/*<![CDATA[*/ |
67 | | - addOnloadHook( |
68 | | - function() { |
69 | | - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], [$this->controls], $this->autozoom, [$markersString], $this->height); |
70 | | - } |
| 71 | + $layerItems = MapsOpenLayers::createLayersStringAndLoadDependencies( $this->output, $this->layers ); |
| 72 | + |
| 73 | + $parser->getOutput()->addHeadItem( |
| 74 | + Html::inlineScript( <<<EOT |
| 75 | +addOnloadHook( |
| 76 | + function() { |
| 77 | + initOpenLayer( |
| 78 | + '$this->mapName', |
| 79 | + $this->centre_lat, |
| 80 | + $this->centre_lon, |
| 81 | + $this->zoom, |
| 82 | + $this->type, |
| 83 | + [$this->types], |
| 84 | + [$this->controls], |
| 85 | + $this->autozoom, |
| 86 | + [$markersString] |
71 | 87 | ); |
72 | | - /*]]>*/</script>"; |
73 | | - |
74 | 88 | } |
| 89 | +); |
| 90 | +EOT |
| 91 | + ) ); |
| 92 | + } |
75 | 93 | |
76 | 94 | /** |
77 | 95 | * Returns type info, descriptions and allowed values for this QP's parameters after adding the spesific ones to the list. |
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsFormInput.php |
— | — | @@ -68,15 +68,38 @@ |
69 | 69 | * |
70 | 70 | */ |
71 | 71 | protected function addSpecificMapHTML( Parser $parser ) { |
72 | | - global $wgJsMimeType; |
| 72 | + $this->output .= Html::element( |
| 73 | + 'div', |
| 74 | + array( |
| 75 | + 'id' => $this->mapName, |
| 76 | + 'style' => "width: $this->width; height: $this->height; background-color: #cccccc;", |
| 77 | + ), |
| 78 | + wfMsg('maps-loading-map') |
| 79 | + ); |
73 | 80 | |
74 | | - $this->output .= " |
75 | | - <div id='" . $this->mapName . "' style='width: {$this->width}px; height: {$this->height}px;'></div> |
76 | | - |
77 | | - <script type='$wgJsMimeType'>/*<![CDATA[*/ |
78 | | - addOnloadHook(function() {makeFormInputYahooMap('$this->mapName', '$this->coordsFieldName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$this->types], [$this->controls], $this->autozoom, $this->marker_lat, $this->centre_lon, $this->height);}); |
79 | | - /*]]>*/</script>"; |
| 81 | + $parser->getOutput()->addHeadItem( |
| 82 | + Html::inlineScript( <<<EOT |
| 83 | +addOnloadHook( |
| 84 | + function() { |
| 85 | + makeFormInputYahooMap( |
| 86 | + '$this->mapName', |
| 87 | + '$this->coordsFieldName', |
| 88 | + $this->centre_lat, |
| 89 | + $this->centre_lon, |
| 90 | + $this->zoom, |
| 91 | + $this->type, |
| 92 | + [$this->types], |
| 93 | + [$this->controls], |
| 94 | + $this->autozoom, |
| 95 | + $this->marker_lat, |
| 96 | + $this->marker_lon |
| 97 | + ); |
80 | 98 | } |
| 99 | +); |
| 100 | +EOT |
| 101 | + ) ); |
| 102 | + |
| 103 | + } |
81 | 104 | |
82 | 105 | /** |
83 | 106 | * @see SMFormInput::manageGeocoding() |
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsFunctions.js |
— | — | @@ -13,8 +13,7 @@ |
14 | 14 | */ |
15 | 15 | function makeGoogleMapFormInput(mapName, locationFieldName, mapOptions, marker_lat, marker_lon) { |
16 | 16 | if (GBrowserIsCompatible()) { |
17 | | - mapOptions.centre = new GLatLng(mapOptions.lat, mapOptions.lon); |
18 | | - mapOptions.size = new GSize(mapOptions.width, mapOptions.height); |
| 17 | + mapOptions.centre = new GLatLng(mapOptions.lat, mapOptions.lon); |
19 | 18 | var map = createGoogleMap(mapName, mapOptions, [getGMarkerData(marker_lat, marker_lon, '', '', '')]); |
20 | 19 | |
21 | 20 | // Show a starting marker only if marker coordinates are provided |