40

google map marker显示问题

最近在研究google map api,但为什么现在添加的marker无法显示了呢,请大侠指点,代码如下:
<!DOCTYPE html>



Google Maps JavaScript API v3 Example: Image MapTypes
function tlen(len, mystr){ mystr = String(mystr); var num = len - mystr.length; for (var i = 0; i <= num; i++) { mystr = "0" + mystr; } return mystr; }; function CoordMapType(tileSize) { this.tileSize = tileSize; } CoordMapType.prototype.getTile = function(coord, zoom, ownerDocument) { var div = ownerDocument.createElement('DIV'); var ymax = 1 << zoom; var y = coord.y; y = tlen(5,y); var x = tlen(5,coord.x); zoom = tlen(1,zoom+1); div.innerHTML = y + "," + x + "," + zoom; div.style.width = this.tileSize.width + 'px'; div.style.height = this.tileSize.height + 'px'; div.style.fontSize = '10'; div.style.borderStyle = 'solid'; div.style.borderWidth = '1px'; div.style.borderColor = '#AAAAAA'; return div; }; function LocalMapType() {} LocalMapType.prototype.tileSize = new google.maps.Size(256, 256); LocalMapType.prototype.maxZoom = 20; LocalMapType.prototype.minZoom = 0; LocalMapType.prototype.name = "本地"; LocalMapType.prototype.alt = "显示本地地图"; LocalMapType.prototype.getTile = function(coord, zoom, ownerDocument) { var img = ownerDocument.createElement("img"); img.style.width = this.tileSize.width + "px"; img.style.height = this.tileSize.height + "px"; var ymax = 1 << zoom; var y = coord.y; y = tlen(5,y); var x = tlen(5,coord.x); zoom = tlen(1,zoom+1); var strURL = "..\\data\\L" + zoom + "\\" + y + "-" + x + ".png"; img.src = strURL; return img; }; var localMapType = new LocalMapType(); function initialize() { var myLatlng = new google.maps.LatLng(30, 103); var myOptions = { center: myLatlng, zoom: 4, streetViewControl: false, mapTypeControlOptions: { mapTypeIds: ["local", google.maps.MapTypeId.ROADMAP] } }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); //map.setMapTypeId('satellite'); //map.MapTypes.insertAt(0, moonMapType); map.mapTypes.set('local', localMapType); map.setMapTypeId('local'); map.overlayMapTypes.insertAt(0, new CoordMapType(new google.maps.Size(256, 256))); var marker = new google.maps.Marker({ position: myLatlng, map: map, }); }





查看全部
purplelotuszyh
purplelotuszyh
2015/09/04 03:47
  • chrome
  • 地图
  • javascript
  • 点赞
  • 收藏
  • 回答
    私信

2个回复