مرجع سبک برای Maps SDK برای iOS

پلتفرم را انتخاب کنید: Android iOS JavaScript

با گزینه‌های سبک می‌توانید نمایش سبک‌های استاندارد نقشه Google را سفارشی کنید، نمایش بصری ویژگی‌هایی مانند جاده‌ها، پارک‌ها، مشاغل و سایر نقاط مورد علاقه را تغییر دهید. و همچنین تغییر سبک این ویژگی ها ، می توانید ویژگی ها را کاملاً پنهان کنید. این بدان معنی است که می توانید بر اجزای خاصی از نقشه تأکید کنید یا نقشه را تکمیل کننده سبک صفحه اطراف کنید.

نمونه ها

اعلان سبک JSON زیر همه ویژگی‌های نقشه را به خاکستری تبدیل می‌کند، سپس هندسه جاده شریانی را به رنگ آبی رنگ می‌کند و برچسب‌های منظره را کاملاً پنهان می‌کند:

[
  {
    "featureType": "all",
    "stylers": [
      { "color": "#C0C0C0" }
    ]
  },{
    "featureType": "road.arterial",
    "elementType": "geometry",
    "stylers": [
      { "color": "#CCFFFF" }
    ]
  },{
    "featureType": "landscape",
    "elementType": "labels",
    "stylers": [
      { "visibility": "off" }
    ]
  }
]

شی JSON

یک اعلان سبک JSON از عناصر زیر تشکیل شده است:

  • FeatureType (اختیاری) - ویژگی هایی که برای این تغییر سبک انتخاب شده اند. ویژگی‌ها ویژگی‌های جغرافیایی روی نقشه هستند، از جمله جاده‌ها، پارک‌ها، توده‌های آبی و غیره. اگر یک ویژگی را مشخص نکنید، همه ویژگی‌ها انتخاب می‌شوند.
  • elementType (اختیاری) - ویژگی ویژگی مشخص شده برای انتخاب. عناصر، بخش‌های فرعی یک ویژگی هستند، از جمله برچسب‌ها و هندسه. اگر عنصری را مشخص نکنید، همه عناصر ویژگی انتخاب می شوند.
  • استایلرها - قوانینی که در مورد ویژگی ها و عناصر انتخاب شده اعمال می شود. Stylers indicate the color, visibility, and weight of the feature. می توانید یک یا چند استایلر را برای یک ویژگی اعمال کنید.

To specify a style, you must combine a set of featureType and elementType selectors and your stylers into a style array. شما می توانید هر ترکیبی از ویژگی ها را در یک آرایه هدف قرار دهید. با این حال، تعداد سبک هایی که می توانید به طور همزمان اعمال کنید محدود است. اگر آرایه سبک شما از حداکثر تعداد کاراکترها بیشتر باشد، هیچ سبکی اعمال نمی شود.

بقیه این صفحه اطلاعات بیشتری در مورد ویژگی ها، عناصر و استایلرها دارد.

featureType

قطعه JSON زیر همه جاده‌های روی نقشه را انتخاب می‌کند:

{
  "featureType": "road"
}

ویژگی‌ها یا انواع ویژگی‌ها، ویژگی‌های جغرافیایی روی نقشه هستند، از جمله جاده‌ها، پارک‌ها، آب‌ها، مشاغل و موارد دیگر.

ویژگی‌ها درخت دسته‌بندی را تشکیل می‌دهند که all آنها ریشه هستند. اگر یک ویژگی را مشخص نکنید، همه ویژگی‌ها انتخاب می‌شوند. مشخص کردن یک ویژگی از all تأثیر یکسانی دارد.

برخی از ویژگی‌ها حاوی ویژگی‌های فرزندی هستند که شما با استفاده از علامت نقطه مشخص می‌کنید. For example, landscape.natural or road.local . اگر فقط ویژگی والد را مشخص کنید، مانند road ، سبک‌هایی که برای والدین مشخص می‌کنید برای همه فرزندانش اعمال می‌شود، مانند road.local و road.highway .

توجه داشته باشید که ویژگی‌های والد ممکن است شامل برخی از عناصر باشد که در همه ویژگی‌های فرزند آنها گنجانده نشده است.

ویژگی های زیر موجود است:

  • all (پیش فرض) تمام ویژگی ها را انتخاب می کند.
  • administrative همه مناطق اداری را انتخاب می کند. استایل‌سازی فقط بر برچسب‌های مناطق اداری تأثیر می‌گذارد، نه مرزهای جغرافیایی یا پر.
    • administrative.country Country کشورها را انتخاب می کند.
    • administrative.land_parcel بسته های زمین را انتخاب می کند.
    • administrative.locality locality محلی ها را انتخاب می کند.
    • administrative.neighborhood محله ها را انتخاب می کند.
    • administrative.province پروانه استانها را انتخاب می کند.
  • landscape selects all landscapes.
    • landscape.man_made selects man-made features, such as buildings and other structures.
    • landscape.natural ویژگی‌های طبیعی مانند کوه‌ها، رودخانه‌ها، بیابان‌ها و یخچال‌های طبیعی را انتخاب می‌کند.
    • landscape.natural.landcover selects land cover features, the physical material that covers the earth's surface, such as forests, grasslands, wetlands, and bare ground.
    • landscape.natural.terrain selects terrain features of a land surface, such as elevation, slope, and orientation.
  • poi selects all points of interest.
    • poi.attraction جاذبه های گردشگری را انتخاب می کند.
    • poi.business selects businesses.
    • poi.government ساختمانهای دولتی را انتخاب می کند.
    • poi.medical خدمات اورژانسی از جمله بیمارستان‌ها، داروخانه‌ها، پلیس، پزشکان و غیره را انتخاب می‌کند.
    • poi.park پارک ها را انتخاب می کند.
    • poi.place_of_worship مکان های عبادت از جمله کلیساها، معابد، مساجد و موارد دیگر را انتخاب می کند.
    • poi.school selects schools.
    • poi.sports_complex selects sports complexes.
  • road همه جاده ها را انتخاب می کند.
    • road.arterial جاده های شریانی را انتخاب می کند.
    • road.highway بزرگراه ها را انتخاب می کند.
    • road.highway.controlled_access بزرگراه هایی با دسترسی کنترل شده را انتخاب می کند.
    • road.local جاده های محلی را انتخاب می کند.
  • transit تمام ایستگاه ها و خطوط حمل و نقل را انتخاب می کند.
    • transit.line خطوط ترانزیت را انتخاب می کند.
    • transit.station تمام ایستگاه های ترانزیت را انتخاب می کند.
    • transit.station.airport فرودگاه ها را انتخاب می کند.
    • transit.station.bus ایستگاه های اتوبوس را انتخاب می کند.
    • transit.station.rail selects rail stations.
  • water توده های آبی را انتخاب می کند.

elementType

The following JSON snippet selects the labels for all local roads:

{
  "featureType": "road.local",
  "elementType": "labels"
}

عناصر زیرمجموعه های یک ویژگی هستند. A road, for example, consists of the graphical line (the geometry) on the map, and also the text denoting its name (a label).

عناصر زیر در دسترس هستند، اما توجه داشته باشید که یک ویژگی خاص ممکن است از هیچ یک، برخی یا همه عناصر پشتیبانی نکند:

Label text fill and stroke colors change based on the zoom level. برای اینکه تجربه در سطوح بزرگنمایی سازگار باشد، همیشه هم fill و هم stroke تعریف کنید.

  • all (پیش فرض) تمام عناصر ویژگی مشخص شده را انتخاب می کند.
  • geometry selects all geometric elements of the specified feature.
    • geometry.fill selects only the fill of the feature's geometry.
    • geometry.stroke selects only the stroke of the feature's geometry.
  • labels selects the textual labels associated with the specified feature.
    • labels.icon selects only the icon displayed within the feature's label.
    • labels.text فقط متن برچسب را انتخاب می کند.
    • labels.text.fill selects only the fill of the label. The fill of a label is typically rendered as a colored outline that surrounds the label text.
    • labels.text.stroke selects only the stroke of the label's text.

stylers

Stylers are formatting options that you can apply to map features and elements.

قطعه JSON زیر با استفاده از یک مقدار RGB ، یک ویژگی را به عنوان سبز روشن نشان می دهد:

"stylers": [
  { "color": "#99FF33" }
]

This snippet removes all intensity from the color of a feature, regardless of its starting color. تأثیر این است که ویژگی خاکستری را ارائه دهید:

"stylers": [
  { "saturation": -100 }
]

این قطعه یک ویژگی را به طور کامل پنهان می کند:

    "stylers": [
      { "visibility": "off" }
    ]

گزینه های سبک زیر پشتیبانی می شوند:

  • hue (an RGB hex string of format #RRGGBB ) indicates the basic color.

    Note: This option sets the hue while keeping the saturation and lightness specified in the default Google style (or in other style options you define on the map). The resulting color is relative to the style of the base map. If Google makes any changes to the base map style, the changes affect your map's features styled with hue . در صورت امکان بهتر است از استایلر color مطلق استفاده کنید.

  • lightness (a floating point value between -100 and 100 ) indicates the percentage change in brightness of the element. Negative values increase darkness (where -100 specifies black) while positive values increase brightness (where +100 specifies white).

    Note: This option sets the lightness while keeping the saturation and hue specified in the default Google style (or in other style options you define on the map). The resulting color is relative to the style of the base map. If Google makes any changes to the base map style, the changes affect your map's features styled with lightness . It's better to use the absolute color styler if you can.

  • saturation (a floating point value between -100 and 100 ) indicates the percentage change in intensity of the basic color to apply to the element.

    Note: This option sets the saturation while keeping the hue and lightness specified in the default Google style (or in other style options you define on the map). The resulting color is relative to the style of the base map. If Google makes any changes to the base map style, the changes affect your map's features styled with saturation . در صورت امکان بهتر است از استایلر color مطلق استفاده کنید.

  • gamma (a floating point value between 0.01 and 10.0 , where 1.0 applies no correction) indicates the amount of gamma correction to apply to the element. Gamma corrections modify the lightness of colors in a non-linear fashion, while not affecting white or black values. Gamma correction is typically used to modify the contrast of multiple elements. به عنوان مثال، می توانید گاما را برای افزایش یا کاهش کنتراست بین لبه ها و فضای داخلی عناصر تغییر دهید.

    Note: This option adjusts the lightness relative to the default Google style, using a gamma curve. If Google makes any changes to the base map style, the changes affect your map's features styled with gamma . It's better to use the absolute color styler if you can.

  • invert_lightness (if true ) inverts the existing lightness. This is useful, for example, for quickly switching to a darker map with white text.

    توجه: این گزینه به سادگی استایل پیش فرض گوگل را معکوس می کند. If Google makes any changes to the base map style, the changes affect your map's features styled with invert_lightness . It's better to use the absolute color styler if you can.

  • visibility ( on , off , or simplified ) indicates whether and how the element appears on the map. یک دید simplified برخی از ویژگی های سبک را از ویژگی های تحت تأثیر حذف می کند. برای مثال، جاده‌ها به خطوط باریک‌تر بدون خطوط اصلی ساده‌سازی می‌شوند، در حالی که پارک‌ها متن برچسب خود را از دست می‌دهند اما نماد برچسب را حفظ می‌کنند.
  • color (an RGB hex string of format #RRGGBB ) sets the color of the feature.
  • weight (یک مقدار صحیح، بزرگتر یا مساوی صفر) وزن ویژگی را بر حسب پیکسل تعیین می کند. Setting the weight to a high value may result in clipping near tile borders.

قوانین سبک به ترتیبی که شما مشخص کرده اید اعمال می شود. چندین عملیات را در یک عملیات سبک ترکیب نکنید. Instead, define each operation as a separate entry in the style array.

توجه: ترتیب مهم است، زیرا برخی از عملیات جابجایی نیستند. ویژگی‌ها و/یا عناصری که از طریق عملیات سبک اصلاح می‌شوند (معمولاً) از قبل دارای سبک‌های موجود هستند. در صورت وجود عملیات بر روی آن سبک های موجود عمل می کند.

مدل رنگ، اشباع، سبکی

نقشه های سبک از مدل رنگ، اشباع، سبکی (HSL) برای نشان دادن رنگ در عملیات استایلر استفاده می کنند. Hue indicates the basic color, saturation indicates the intensity of that color, and lightness indicates the relative amount of white or black in the constituent color.

تصحیح گاما روشنایی فضای رنگ را تغییر می دهد، به طور کلی برای افزایش یا کاهش کنتراست. Additionally, the HSL model defines color within a coordinate space where hue indicates the orientation within a color wheel, while saturation and lightness indicate amplitudes along different axes. Hues are measured within an RGB color space, which is similar to most RGB color spaces, except that shades of white and black are absent.

مدل رنگ، اشباع، سبکی

While hue takes an HTML hex color value, it only uses this value to determine the basic color - that is, its orientation around the color wheel, not its saturation or lightness, which are indicated separately as percentage changes.

For example, you can define the hue for pure green as hue:0x00ff00 or hue:0x000100 . هر دو رنگ یکسان هستند. Both values point to pure green in the HSL color model.

یک چرخ رنگی RGB

RGB hue values which consist of equal parts red, green and blue do not indicate a hue, because none of those values indicate an orientation in the HSL coordinate space. Examples are "#000000" (black), "#FFFFFF" (white), and all the pure shades of gray. To indicate black, white or gray, you must remove all saturation (set the value to -100 ) and adjust lightness instead.

Additionally, when modifying existing features which already have a color scheme, changing a value such as hue does not change its existing saturation or lightness .