Index: branches/Maps0.8/includes/Maps_Mapper.php |
— | — | @@ -157,4 +157,30 @@ |
158 | 158 | return $image; |
159 | 159 | } |
160 | 160 | |
| 161 | + /** |
| 162 | + * Returns JS to init the vars to hold the map data when they are not there already. |
| 163 | + * |
| 164 | + * @since 0.8 |
| 165 | + * |
| 166 | + * @param string $serviceName |
| 167 | + */ |
| 168 | + public static function getBaseMapJSON( $serviceName ) { |
| 169 | + static $baseInit = false; |
| 170 | + static $serviceInit = array(); |
| 171 | + |
| 172 | + $json = ''; |
| 173 | + |
| 174 | + if ( !$baseInit ) { |
| 175 | + $baseInit = true; |
| 176 | + $json .= 'var maps={};'; |
| 177 | + } |
| 178 | + |
| 179 | + if ( !in_array( $serviceName, $serviceInit ) ) { |
| 180 | + $serviceInit[] = $serviceName; |
| 181 | + $json .= "maps.$serviceName={};"; |
| 182 | + } |
| 183 | + |
| 184 | + return $json; |
| 185 | + } |
| 186 | + |
161 | 187 | } |
\ No newline at end of file |
Index: branches/Maps0.8/includes/features/Maps_BasePointMap.php |
— | — | @@ -106,8 +106,10 @@ |
107 | 107 | return ''; |
108 | 108 | } |
109 | 109 | |
110 | | - // TODO |
111 | | - return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}']['{$mapName}']=" . json_encode( $object ) . ';' ); |
| 110 | + return Html::inlineScript( |
| 111 | + MapsMapper::getBaseMapJSON( $this->service->getName() ) |
| 112 | + . "maps.{$this->service->getName()}.{$mapName}=" . json_encode( $object ) . ';' |
| 113 | + ); |
112 | 114 | } |
113 | 115 | |
114 | 116 | /** |
Index: branches/Maps0.8/includes/features/Maps_BaseMap.php |
— | — | @@ -108,8 +108,10 @@ |
109 | 109 | return ''; |
110 | 110 | } |
111 | 111 | |
112 | | - // TODO |
113 | | - return Html::inlineScript( "maps=[]; maps['{$this->service->getName()}']=[]; maps['{$this->service->getName()}']['{$mapName}']=" . json_encode( $object ) . ';' ); |
| 112 | + return Html::inlineScript( |
| 113 | + MapsMapper::getBaseMapJSON( $this->service->getName() ) |
| 114 | + . "maps.{$this->service->getName()}.{$mapName}=" . json_encode( $object ) . ';' |
| 115 | + ); |
114 | 116 | } |
115 | 117 | |
116 | 118 | /** |