使用javascript在iOS中从图像资源中获取图像,放置Google地图标记图标

使用javascript在iOS中从图像资源中获取图像,放置Google地图标记图标,javascript,ios,google-maps,google-maps-api-3,Javascript,Ios,Google Maps,Google Maps Api 3,嗨,我正在尝试使用javascript在谷歌地图中设置标记图标。我的图像位于Images.xcsets中。现在我这样做是为了设置图标。但这对我不起作用。我现在做的是: setMarkerWithIcon('/Images/MapScreen/MapviewIcon/MapviewIcon'); function initialize(latitude, longitude, maxzoom) { var styles = [{ elementType: "labels",

嗨,我正在尝试使用javascript在谷歌地图中设置标记图标。我的图像位于Images.xcsets中。现在我这样做是为了设置图标。但这对我不起作用。我现在做的是:

setMarkerWithIcon('/Images/MapScreen/MapviewIcon/MapviewIcon');

function initialize(latitude, longitude, maxzoom) {
var styles = [{
          elementType: "labels",
          stylers: [
                    { visibility: "off" }
                    ]
          }];

var styledMap = new google.maps.StyledMapType(styles,
                                              {name: "Styled Map"});

var mapOptions = {
zoom: initialZoomLevel,
center: new google.maps.LatLng(latitude + LatLngDeltas[ randomIntFromInterval(0, LatLngDeltas.length) ],
                               longitude + LatLngDeltas[ randomIntFromInterval(0, LatLngDeltas.length) ] ),
disableDefaultUI: true,
disableDoubleClickZoom: false,
minZoom: initialZoomLevel,
maxZoom: maxzoom,
scrollwheel: false,
scaleControl: false,
rotateControl:true,
rotateControlOptions: {
position: google.maps.ControlPosition.LEFT_CENTER
},
mapTypeControl: false,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style']
}
};
var map = new google.maps.Map(document.getElementById('map-canvas'),
                              mapOptions);

map.mapTypes.set('map_style', styledMap);
map.setMapTypeId('map_style');

google.maps.event.addListener(map, 'click', function(event) {
                              addMarker(map, event.latLng);
                              });
}

function addMarker(mapObject, location) {
deleteMarkers();
var marker = new google.maps.Marker({
                                    position: location,
                                    draggable:true,
                                    animation: google.maps.Animation.DROP,
                                    map: mapObject,
                                    icon:markerPath
                                    });
setTimeout(function() {infowindow.open(mapObject,marker);}, 500);
google.maps.event.addListener(marker, 'click', function() {
                              infowindow.open(mapObject,marker);
                              });
markers.push(marker);
}

function setMarkerWithIcon(myIcon) {
markerPath = myIcon;
}

非常感谢您的帮助。

markerPath在哪里声明?或者,你可以试着把图片放在某个地方,并传递一个URL,看看它是否有效;在本例中,此图像位于项目包中。