最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Google Maps Javascript API fill color of buildings - Stack Overflow

programmeradmin1浏览0评论

I am aware my question is very similar to Google map building style

However, the solution provided there doesn't seem to achieve my goal.

I am trying to use a custom map style to change the fill color of buildings. When I set landscape.man_made with geometry.fill it sets that color for the landscape of all urban areas and when I set geometry.stroke it sets that color for building outlines.

My question is can I specifically set the fill color for buildings only and if so can you provide a simple code sample of what the JSON would look like?

EDIT

It seems as though this may not be possible by default. Does anyone know if there is a way then to retrieve the geometry of a featureType? I will be doing my own looking but my idea is if that data can be gotten, then custom shapes could be drawn on the map corresponding to the outlines (landscape.man_made -> geometry.stroke) with the desired fill color. If I find anything I will update here, but it anyone already knows how to retrieve the information it would be helpful.

I am aware my question is very similar to Google map building style

However, the solution provided there doesn't seem to achieve my goal.

I am trying to use a custom map style to change the fill color of buildings. When I set landscape.man_made with geometry.fill it sets that color for the landscape of all urban areas and when I set geometry.stroke it sets that color for building outlines.

My question is can I specifically set the fill color for buildings only and if so can you provide a simple code sample of what the JSON would look like?

EDIT

It seems as though this may not be possible by default. Does anyone know if there is a way then to retrieve the geometry of a featureType? I will be doing my own looking but my idea is if that data can be gotten, then custom shapes could be drawn on the map corresponding to the outlines (landscape.man_made -> geometry.stroke) with the desired fill color. If I find anything I will update here, but it anyone already knows how to retrieve the information it would be helpful.

Share Improve this question edited May 23, 2017 at 11:51 CommunityBot 11 silver badge asked Aug 31, 2016 at 13:26 FatalKeystrokeFatalKeystroke 3,0427 gold badges25 silver badges36 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 9

UPDATE 2022!

It is possible by:

{
  featureType: "landscape.man_made.building",
  elementType: "geometry.fill",
  stylers: [ 
    { color: "#ffff00"} ]
}

After researching further I have determined it's curently not possible to achieve my desired result with the Google Maps API.

It does seem that it's possible to retrieve individual map tiles and process them such that it replaces the default building color with a more unique one, then use that image to find building borders and their corner coordinates to dray a polygon over the map. However, this seems an extraneous amount of work and processing for such a result, especially if you want to do it to all the building on the screen as I do.

Check out the Google maps JSON style guide for your exact needs.

Maybe

var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40.674, lng: -73.945},
zoom: 12,
styles: [
   {
     featureType: 'poi',
     stylers: [
       { "color": "#99FF33" }
     ]
   }, {
    featureType: "landscape.man_made ",
    stylers: [
       { "color": "#99FF33" }
     ]
   }
 ]
});
发布评论

评论列表(0)

  1. 暂无评论