2012-08-09 28 views
0

我似乎无法让我的地图标记显示,当我在iphone上使用图像精灵。当我在iPhone上使用标准Google地图标记时,以及在桌面上查看站点时,它们会出现,这些精灵图标可以正常工作。谷歌地图制造商在OSX的雪碧不显示

这里是我用来创建标记的代码,我使用Zepto,但JQuery可以轻松应用。

$.ajax({ 
    dataType: 'jsonp', 
    url: myLocations.LocatorUrl, 
    timeout: 8000, 
    success: function(data) { 
     var infoWindow = new google.maps.InfoWindow(); 
     var bounds = new google.maps.LatLngBounds();        
     $.each(data, function(index, item){     
      var data = item, pincolor, 
      latLng = new google.maps.LatLng(data.lat, data.lng); 
      var d = 'http://blah'; 
      var pinImage = new google.maps.MarkerImage(d+"/assets/img/sprite.locator.png",       
         new google.maps.Size(24, 36), 
         new google.maps.Point(0,25), 
         new google.maps.Point(10, 34)); 
      // Creating a marker and putting it on the map 
       var marker = new google.maps.Marker({ 
        position: latLng, 
        map: map, 
        title: data.type, 
        icon: pinImage 

       }); 

       bounds.extend(latLng); // Extend the Latlng bound method      
       var bubbleHtml = '<div class="bubble"><h2>'+item.type+'</h2><p>'+item.address+'</p></div>'; // Custom HTML for the bubble 
       (function(marker, data) {     
        // Attaching a click event to the current marker     
        google.maps.event.addListener(marker, "click", function(e) {     
        infoWindow.setContent(bubbleHtml); 
        infoWindow.open(map, marker); 
        }); 
        markers.push(marker); // Push markers into an array so they can be removed 
       })(marker, data); 
      }); 
      map.fitBounds(bounds); // Center based on values added to bounds   
     }, error: function(x, t, m) { 
      console.log('errors') 
      if(t==="timeout") { 
       alert("got timeout"); 
      } else { 
       alert(t); 
      } 
     } 
    }); 

回答

0

明白了。原来我引用的映像是在本地主机上,当我将其交换到本地机器的实际IP地址时,它就起作用了。