Как изменить маркер в Google Maps в чужом коде? Пытался через этот способ:
image = 'images/icon_mapss.png',
marker = new google.maps.Marker({
map: window.GLOBAL_arMapObjects['MAP_PxWcPa'],
position: place.geometry.location
icon: image
});
Если поможет, то вот весь код, который я нашел по картам
<div class="bx-yandex-view-map">
<script>
if (!window.GLOBAL_arMapObjects)
window.GLOBAL_arMapObjects = {};
function init_MAP_PxWcPa()
{
if (!window.google || !window.google.maps)
return;
var opts = {
zoom: 16,
center: new google.maps.LatLng(55.763755, 37.553732),
styles:[
{
"featureType": "administrative",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#444444"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry",
"stylers": [
{
"hue": "#333333"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry.fill",
"stylers": [
{
"hue": "#777777"
},
{
"visibility": "on"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#46bcec"
},
{
"visibility": "on"
}
]
}
],
scrollwheel: false,
disableDoubleClickZoom: false,
draggable: true,
keyboardShortcuts: false,
mapTypeControl: false,
zoomControl: false,
scaleControl: false,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
window.GLOBAL_arMapObjects['MAP_PxWcPa'] = new window.google.maps.Map(BX("BX_GMAP_MAP_PxWcPa"), opts);
infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(window.GLOBAL_arMapObjects['MAP_PxWcPa']);
service.nearbySearch({
location: [55.763755, 37.553732],
radius: 10000,
type: ['subway_station']
}, callback);
function callback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}
function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: window.GLOBAL_arMapObjects['MAP_PxWcPa'],
position: place.geometry.location
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(place.name);
infowindow.open(window.GLOBAL_arMapObjects['MAP_PxWcPa'], this);
});
}
}
BX.ready(init_MAP_PxWcPa);
/* if map inits in hidden block (display:none),
* after the block showed,
* for properly showing map this function must be called
*/
function BXMapGoogleAfterShow(mapId)
{
if(google.maps !== undefined && window.GLOBAL_arMapObjects[mapId] !== undefined)
google.maps.event.trigger(window.GLOBAL_arMapObjects[mapId],'resize');
}
</script>
<div id="BX_GMAP_MAP_PxWcPa" class="bx-google-map" style="height: 100%; width: 100%;">загрузка карты...</div> </div>
</div>
<script type="text/javascript">
function BX_SetPlacemarks_MAP_PxWcPa()
{
BX_GMapAddPlacemark({'TEXT':'Москва, ст.метро Улица 1905 года, Звенигородское шоссе, д. 5, стр.1','LON':'37.553732','LAT':'55.763755'}, 'MAP_PxWcPa');
}
function BXShowMap_MAP_PxWcPa() {
if(typeof window["BXWaitForMap_view"] == 'function')
{
BXWaitForMap_view('MAP_PxWcPa');
}
else
{
/* If component's result was cached as html,
* script.js will not been loaded next time.
* let's do it manualy.
*/
(function(d, s, id)
{
var js, bx_gm = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "/bitrix/templates/universe_s1/components/bitrix/map.google.view/.default/script.js";
bx_gm.parentNode.insertBefore(js, bx_gm);
}(document, 'script', 'bx-google-map-js'));
var gmWaitIntervalId = setInterval( function(){
if(typeof window["BXWaitForMap_view"] == 'function')
{
BXWaitForMap_view("MAP_PxWcPa");
clearInterval(gmWaitIntervalId);
}
}, 300
);
}
}
BX.ready(BXShowMap_MAP_PxWcPa);
</script>