ext太深高,结合googleMap真是蛋疼,下面是2个页面的跨域访问
你妹的调了一上午,结果有2个错误找了半天没找到
1.不能再render回调函数中调用getRemoteJs,此时html:还未实例化,无法找到<iframe>
2.Document.doamin中的Document要大写。。你妹的,这什么命名规则啊
你妹的调了一上午,结果有2个错误找了半天没找到
1.不能再render回调函数中调用getRemoteJs,此时html:还未实例化,无法找到<iframe>
2.Document.doamin中的Document要大写。。你妹的,这什么命名规则啊
var map;
var geocoder;
function getRemoteJS(){
alert("getRemoteJs~");
Document.domain="test1.com";
var remoteHtml;
remoteHtml=document.getElementById("googleMap").contentDocument.getElementById("address").value;
if(remoteHtml)
alert("address"+remoteHtml);
else
alert("false");
}
function findAddress(){
var address = text_search_city.getValue();
if(map)
alert(address);
else
alert("false");
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
function showMap(){
document.domain='test1.com';
var remoteHtml;
remoteHtml=document.getElementById("googleMap").contentDocument;
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
if(remoteHtml.getElementById("map_canvas"))
{map = new google.maps.Map(remoteHtml.getElementById("map_canvas"), myOptions);
alert("success");
}
else
alert("false");
}
var btn_search_city=new Ext.Button(
{
text : '查询',
iconCls : 'icon-search',
handler : getRemoteJS
});
var text_search_city=new Ext.form.TextField({
id:'testSearchCity',
name : 'textSearchCity',
width : 200,
emptyText : '多条件可用逗号或者空格隔开!',
listeners : {
'specialkey' : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
getRemoteJS();
}
}
}
});
function test(){
alert("aaaa");
}
var googleMap_panel=new Ext.Panel({
title : 'googleMap',
iconCls : 'icon-plugin',
region : 'center',
border : 'layout',
frame : true,
layout:'fit',
height:'100%',
//defaults: {
// collapsible: true,
// split: true
//},
tbar:[text_search_city,btn_search_city],
listeners:{
//render:getRemoteJS
},
items:[{
title:'hellow',
height:'100%',
id:'mapPanel',
//html:'<div id="map_canvas" style="height:90%;background-color:red">cc</div>'
html:'<iframe id="googleMap" scrolling="no" border="0" width="970" height="700" src="http://www.test1.com:9001/bmsh/test2.html"> </iframe>',
listeners:{
//render:getRemoteJS
}
}]
});
var p_googleMap={
id:'googleMap-panel',
border : false,
layout : 'border',
items : [googleMap_panel]
};