【问题标题】:Google Map Makers Sprite in OSX not displayingOSX中的Google Map Makers Sprite不显示
【发布时间】:2012-08-06 12:56:18
【问题描述】:

当我在 iphone 上使用图像精灵时,我似乎无法显示我的地图标记。当我在 iphone 上使用标准的谷歌地图标记并且在桌面上查看站点时,精灵图标工作正常。

这是我用来创建标记的代码,我使用的是 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);
            }
        }
    });

【问题讨论】:

    标签: iphone ios google-maps-api-3 google-maps-markers


    【解决方案1】:

    知道了。原来我引用的图像在本地主机上,当我将它交换到它工作的本地机器的实际 IP 地址时。

    【讨论】:

      猜你喜欢
      • 2022-11-12
      • 1970-01-01
      • 2018-05-19
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多