javascript - Style google maps -
i have fowlling google map created own icon. code fowlling:
however want ot add style silver, i'm not sure how modify code.
any apprecaited.
thanks!
please follow code.
here need add google api key in below link.
src="https://maps.googleapis.com/maps/api/jskey=your_api_key&callback=initmap"
here code.
var map; function initmap() { map = new google.maps.map(document.getelementbyid('map'), { zoom: 16, center: new google.maps.latlng(38.769671, -9.097975), maptypeid: 'roadmap', styles : [ { "elementtype": "geometry", "stylers": [ { "color": "#f5f5f5" } ] }, { "elementtype": "labels.icon", "stylers": [ { "visibility": "off" } ] }, { "elementtype": "labels.text.fill", "stylers": [ { "color": "#616161" } ] }, { "elementtype": "labels.text.stroke", "stylers": [ { "color": "#f5f5f5" } ] }, { "featuretype": "administrative.land_parcel", "elementtype": "labels.text.fill", "stylers": [ { "color": "#bdbdbd" } ] }, { "featuretype": "poi", "elementtype": "geometry", "stylers": [ { "color": "#eeeeee" } ] }, { "featuretype": "poi", "elementtype": "labels.text.fill", "stylers": [ { "color": "#757575" } ] }, { "featuretype": "poi.park", "elementtype": "geometry", "stylers": [ { "color": "#e5e5e5" } ] }, { "featuretype": "poi.park", "elementtype": "labels.text.fill", "stylers": [ { "color": "#9e9e9e" } ] }, { "featuretype": "road", "elementtype": "geometry", "stylers": [ { "color": "#ffffff" } ] }, { "featuretype": "road.arterial", "elementtype": "labels.text.fill", "stylers": [ { "color": "#757575" } ] }, { "featuretype": "road.highway", "elementtype": "geometry", "stylers": [ { "color": "#dadada" } ] }, { "featuretype": "road.highway", "elementtype": "labels.text.fill", "stylers": [ { "color": "#616161" } ] }, { "featuretype": "road.local", "elementtype": "labels.text.fill", "stylers": [ { "color": "#9e9e9e" } ] }, { "featuretype": "transit.line", "elementtype": "geometry", "stylers": [ { "color": "#e5e5e5" } ] }, { "featuretype": "transit.station", "elementtype": "geometry", "stylers": [ { "color": "#eeeeee" } ] }, { "featuretype": "water", "elementtype": "geometry", "stylers": [ { "color": "#c9c9c9" } ] }, { "featuretype": "water", "elementtype": "labels.text.fill", "stylers": [ { "color": "#9e9e9e" } ] } ] }); var iconbase = 'https://maps.google.com/mapfiles/kml/shapes/'; var icons = { info: { icon: 'https://novo2.rhp.pt/map.png' } }; var features = [ { position: new google.maps.latlng(38.769671, -9.097975), type: 'info' } ]; // create markers. features.foreach(function(feature) { var marker = new google.maps.marker({ position: feature.position, icon: icons[feature.type].icon, map: map, content:'<div>test</div>' }); }); }
/* set map height explicitly define size of div * element contains map. */ #map { height: 100%; } /* optional: makes sample page fill window. */ html, body { height: 100%; margin: 0; padding: 0; }
<div id="map"></div> <script async defer src="https://maps.googleapis.com/maps/api/js?key=your_api_key&callback=initmap"> </script>
if wanted still changes map style follow link https://mapstyle.withgoogle.com/ , create whatever want , copy whole json code , replace in above styles
object.
hope helps.
Comments
Post a Comment