如何在Gmap3中使用卫星地图?网站Gmap3切换卫星地图技术咨询
Switching to Satellite Map in Gmap3
Got it, let's get your Gmap3 instance showing satellite imagery instead of that custom shade of grey map. Since Gmap3 wraps the Google Maps JavaScript API, we just need to adjust a few parameters in your initialization code. Here's how:
Key Changes to Make
- Replace the custom map type with Google's satellite option: Google Maps offers two satellite-related map types:
google.maps.MapTypeId.SATELLITE: Pure satellite imagery (no road labels)google.maps.MapTypeId.HYBRID: Satellite imagery with overlaid road labels and place names
- Update the available map types list: If you want to let users switch between map types later, make sure the satellite type is included in the
mapTypeIdsarray. If you don't need the customshadeOfGreymap anymore, you can remove it entirely.
Modified Code Example
$('.map').gmap3({ center:[37.7638886, -122.4563572], zoom:14, scrollwheel: false, mapTypeControl: false, // Keep this false if you don't want users to switch map types; set to true if you do streetViewControl: false, mapTypeId: google.maps.MapTypeId.SATELLITE, // Sets satellite as the default map type mapTypeControlOptions: { mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE] // Include only the map types you want available } });
Quick Notes
- If you prefer hybrid view, just swap out
google.maps.MapTypeId.SATELLITEwithgoogle.maps.MapTypeId.HYBRIDin both themapTypeIdandmapTypeIdsarray. - If you’re sticking with only satellite view (and don’t need the map type control), you can simplify the code further by removing the
mapTypeControlOptionsblock entirely—sincemapTypeControlis set to false, users won’t see the switcher anyway. - Don’t forget to remove any code you had defining the custom
shadeOfGreymap type if you’re no longer using it.
内容的提问来源于stack exchange,提问作者Md Shahnur Sarder
相关产品推荐
相关产品推荐

