[Bug] MapTypeControl cannot switch from hybrid/satellite to roadmap when initialized with hybrid/satellite in 45° imagery areas
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
調査の方向性
Map コンポーネントの静的な mapTypeId 処理と、レポートで説明されている mapTypeId/onMapTypeIdChanged の経路から始めます。45°画像のエリアで最小限の例を再現し、その後、reconciliation によって初期値が復元されるかを追跡します。完了の条件は、ネイティブの Map コントロールが hybrid または satellite から roadmap に切り替わっても元に戻らないことです。
索引モデルが issue の本文から書いたものです。
説明
Description
When a map is initialized with mapTypeId="hybrid" or mapTypeId="satellite" and the user is viewing a location with 45° imagery available, clicking the "Map" button in the native mapTypeControl fails to switch to roadmap view.
The map briefly flickers (appears to attempt the switch) but immediately reverts back to hybrid/satellite view. This only occurs in areas where 45° imagery is available and at zoom levels where tilt is active.
Workarounds
Option 1: Controlled state with onMapTypeIdChanged
Using React state to manage mapTypeId and syncing it via onMapTypeIdChanged resolves the issue:
import { APIProvider, Map, type MapProps } from '@vis.gl/react-google-maps'
import { useState } from 'react'
const MAP_ID = 'YOUR_MAP_ID' // Must have vector maps enabled
function App() {
const [mapTypeId, setMapTypeId] = useState<MapProps['mapTypeId']>('hybrid')
return (
<APIProvider apiKey="YOUR_API_KEY">
<Map
style={{ width: '100%', height: '500px' }}
defaultCenter={{ lat: 48.8630, lng: 2.3622 }} // Paris 3e - has 45° imagery
defaultZoom={18}
mapTypeId={mapTypeId}
mapTypeControl
mapId={MAP_ID}
onMapTypeIdChanged={(event) => setMapTypeId(event.map.getMapTypeId())}
/>
</APIProvider>
)
}
Option 2: Initialize as roadmap and switch after mount
Initializing without mapTypeId prop and programmatically switching to hybrid after mount also works:
import { APIProvider, Map, useMap } from '@vis.gl/react-google-maps'
import { useEffect } from 'react'
const MAP_ID = 'YOUR_MAP_ID' // Must have vector maps enabled
const SwitchToHybridOnMount = () => {
const map = useMap()
useEffect(() => {
if (!map) return
const timer = setTimeout(() => {
map.setMapTypeId('hybrid')
}, 50)
return () => clearTimeout(timer)
}, [map])
return null
}
function App() {
return (
<APIProvider apiKey="YOUR_API_KEY">
<Map
style={{ width: '100%', height: '500px' }}
defaultCenter={{ lat: 48.8630, lng: 2.3622 }} // Paris 3e - has 45° imagery
defaultZoom={18}
// Note: mapTypeId prop must NOT be provided (even undefined won't work)
mapTypeControl
mapId={MAP_ID}
>
<SwitchToHybridOnMount />
</Map>
</APIProvider>
)
}
Observations
- ✅ Works: Initialize with
roadmaporterrain→ switch to hybrid → switch back to roadmap - ❌ Fails: Initialize with
hybridorsatellite→ cannot switch to roadmap (in 45° areas) - ✅ Works: Same scenario in non-45° areas (low zoom or locations without 45° imagery)
- ✅ Works: Native Google Maps API without react-google-maps wrapper (tested via Google's demo)
- ✅ Works: Using controlled state with
onMapTypeIdChangedto syncmapTypeId - ✅ Works: Not providing
mapTypeIdprop and switching viamap.setMapTypeId()after mount
Possible causes
- When
mapTypeIdis passed as a static prop, the library may be forcing it back to the initial value on every camera/tilt change event - The internal reconciliation between Google Maps state and React props seems to conflict with the automatic tilt behavior in 45° areas
- Using controlled state via
onMapTypeIdChangedallows the component to accept the new mapTypeId from Google Maps instead of reverting it - Not providing the
mapTypeIdprop at all lets Google Maps maintain full control over the map type state
Steps to Reproduce
- Initialize a map with
mapTypeId="hybrid"ormapTypeId="satellite"as a static prop (not via useState) - Navigate to a location with 45° imagery (e.g., Paris 3e Arrondissement)
- Zoom in until the 45° tilt view activates
- Click the "Map" button in the mapTypeControl
- Expected: Map switches to roadmap view
- Actual: Map flickers briefly then stays in hybrid/satellite view
Minimal reproduction
import { APIProvider, Map } from '@vis.gl/react-google-maps'
const MAP_ID = 'YOUR_MAP_ID' // Must have vector maps enabled
function App() {
return (
<APIProvider apiKey="YOUR_API_KEY">
<Map
style={{ width: '100%', height: '500px' }}
defaultCenter={{ lat: 48.8630, lng: 2.3622 }} // Paris 3e - has 45° imagery
defaultZoom={18}
mapTypeId="hybrid" // Bug occurs with static hybrid or satellite
mapTypeControl
mapId={MAP_ID}
/>
</APIProvider>
)
}
Environment
- Library version:
^1.7.1 - Google maps version:
3.62 - Browser and Version:
Firefox 147.0.1 - OS:
macOS Tahoe 26.2
Logs
As of version 3.62, Maps JavaScript API satellite and hybrid map types will no longer automatically switch to 45° Imagery at higher zoom levels. For more info, see https://developers.google.com/maps/deprecations
(I know it's outdated, but as long as it works, I'd like to use it)
- 主要言語
- TypeScript
- スター
- 1.9k
- フォーク
- 195
- 平均マージ
- 2日 11時間
- マージ済み PR(30日)
- 14
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
visgl/react-google-maps のほかの issue
-
bug needs more info
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#1039 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
visgl/react-google-maps#918 · コメント 9 件 ·
メンテナーはふだん 2 日以内に返信
-
google maps issue
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
visgl/react-google-maps#889 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
visgl/react-google-maps#884 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
visgl/react-google-maps#877 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
visgl/react-google-maps の issue をすべて見る
似ている issue
-
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
supabase/agent-skills#611 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
polka-codes/test#345 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 92/100
GoogleChromeLabs/project-sesame#217 ·
メンテナーはふだん 12 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
solana-foundation/solana-com#2202 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100