-1
jQuery(document).ready(function($) {
var currentMap;var lat;var log;var latlongarray;var latitude;
var longitude;var count = 0;var name;var number;var country;
var maps;var address;var marker;var batch = [];
showTooltip = function(marker) {
tooltip.innerHTML = marker.tooltip;
var point = currentMap.getCurrentMapType().getProjection()
.fromLatLngToPixel(currentMap.fromDivPixelToLatLng(
new GPoint(0, 0),true),currentMap.getZoom());
var offset = currentMap.getCurrentMapType().getProjection()
.fromLatLngToPixel(marker.getPoint(),
currentMap.getZoom());
var anchor = marker.getIcon().iconAnchor;
var width = marker.getIcon().iconSize.width;
var height = tooltip.clientHeight;
var pos = new GControlPosition(G_ANCHOR_TOP_LEFT,
new GSize(offset.x - point.x - anchor.x + width,
offset.y - point.y - anchor.y - width));
pos.apply(tooltip);
tooltip.style.visibility = "visible";
}
initialize = function() {var tim = (new Date).getTime();
var provNum = $("input[name='providerNumber']").val();
$.getJSON('newmap.do?t=' + tim+ '&providerNumber='+ provNum,
function(data) {$.each(data,function(i,item) {
address = item.name + item.address;
name = item.name;
latitude = item.lattitude;
longitude = item.longitude;
number = item.number;
var icon = new GIcon();
icon.image = "images/pin.png";
icon.iconAnchor = new GPoint(16,16);
icon.infoWindowAnchor = new GPoint(16,0);
icon.iconSize = new GSize(32,32);
icon.shadowSize = new GSize(59,32);
marker = new GMarker(new GLatLng(item.lattitude,
item.longitude),{
draggable : true,
icon : icon
});
lat = item.lattitude;
log = item.longitude;
marker.disableDragging();
batch.push(marker);
marker.tooltip = "<div class='tooltip'>"+item.name+
'<br>'+ item.number+'<br>BEDS:'+ item.bed
+ '<br>DSH: '+ item.dsh+ "</div>";
GEvent.addListener(marker,"mouseover",function() {
showTooltip(marker);
});
GEvent.addListener(marker,"mouseout",function() {
tooltip.style.visibility = "hidden";
});
GEvent.addListener(marker,"mouseout",function() {
tooltip.style.visibility = "hidden";
});
});
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map-c"));
map.setCenter(new GLatLng(lat,log),11);
tooltip = document.createElement("div");
map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
tooltip.style.visibility = "hidden";
map.setUIToDefault();
mgr = new MarkerManager(map);
mgr.addMarkers(batch,2);
mgr.refresh();
currentMap = map;
}
});
});
}
if (jQuery.browser.safari&& document.readyState != "complete") {
initialize();
}
});
這是我的代碼..在這裏IAM越來越lattitude和經度從SQL和谷歌map.Now IAM添加標記嘗試添加信息框每個標記 但我得到一個錯誤 「未捕獲TypeError:pos.apply不是一個函數」 在線 「pos.apply(tooltip);」 有誰知道如何解決這個問題?遺漏的類型錯誤:pos.apply不showtooltip函數()方法
張貼的代碼是從已廢棄和關閉谷歌地圖JavaScript API第2](HTTP://計算器。 com/tags/google-maps-api-2/info),該版本不應該用於新代碼。 – geocodezip