0
如果javascript被調用或執行,依賴於什麼?我有兩個功能,這都被調用以同樣的方式,要精確:什麼時候對javascript函數的objective-c調用被調用/執行,什麼時候不調用?
[self.mapView stringByEvaluatingJavaScriptFromString:
[NSString stringWithFormat:@"setMarkerAtPosition(%f,%f)",
latlong.latitude, latlong.longitude]];
和
[self.mapView stringByEvaluatingJavaScriptFromString:@"test()"];
但calculateRoute()
被執行,而test()
不是。怎麼來的?
function setMarkerAtPosition(lat, long){
var position = new google.maps.LatLng(lat, long);
var marker = new google.maps.Marker({position: position,
map: map,
title:"Hello World!",
animation: google.maps.Animation.DROP});
var content = "Ich bin eine normale Infobox";
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(content);
infowindow.open(map,marker);
reportClickedMarker();
});
}
function test(){
alert(currentPosition.latitude + ', ' + currentPosition.longitude);
}
謝謝
你可能需要證明被調用這些功能 – jmort253
它比函數名 – MJB
好吧,你是不一樣的其他代碼得到我。你需要包含調用這些函數的代碼;否則,你的問題的答案是「你的猜測和我一樣好」。不要將它作爲註釋加入,請實際**編輯**您的問題,其餘代碼在這裏介紹。謝謝;) – jmort253