我一直在試圖調試,沒有運氣。當我看着堆棧,並且它觸及了我設置的所有中斷點(假設類型是多邊形,並且我放了所有應該出現的中斷)時,我有一個通過開關盒掉落的情況。我打了每一個,但它失敗了。所以..這是第一個可以工作的人。通過開關盒跌倒使谷歌地圖元素似乎失敗
that works ..我得到谷歌地圖元素出來就好。現在有了變化,當我再次調試我打了所有破發點_OP對象填充有它的屬性填充...但沒有...
function create_map_element(type,op,map){
var _op={};
defined(map) ?_op.map=map:null;
switch(type){
case "polygon": case "polyline" : case "rectangle" : case "circle" : case "marker" :
defined(op.clickable) ?_op.clickable=op.clickable:null;
defined(op.visible) ?_op.visible=op.visible:null;
defined(op.zIndex) ?_op.zIndex=op.zIndex:null;
case "polygon": case "polyline" : case "rectangle" : case "circle" :
defined(op.strokeColor) ?_op.strokeColor=op.strokeColor:null;
defined(op.strokeOpacity) ?_op.strokeOpacity=op.strokeOpacity:null;
defined(op.strokeWeight) ?_op.strokeWeight=op.strokeWeight:null;
case "polygon": case "rectangle" : case "circle" :
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
case "polygon": case "polyline" :
defined(op.geodesic) ?_op.geodesic=op.geodesic:null;
case "marker" :
defined(op.animation) ?_op.animation=op.animation:null;
case "polygon" :
return new google.maps.Polygon(_op);
break;
case "rectangle" :
return new google.maps.Rectangle(_op);
break;
case "circle" :
return new google.maps.Circle(_op);
break;
case "polyline" :
return new google.maps.Polyline(_op);
break;
case "marker" :
return new google.maps.Marker(_op);
break;
};
}
但是,當我設置的retrun線的破發點,它擊中它,並且所有看起來正確..但是..沒什麼。任何人有一個想法?謝謝 - 傑里米
[編輯] 基礎上,嗯,我不知道是誰刪除了他們的anwser但當時的情況SWTICH失敗的原因在正確的軌道上......這裏是我的選擇正試圖用與上述相同的想法來做。
function create_map_element(type,op,map){
var _op={};
defined(map)?_op.map=map:null;
defined(op.clickable) ?_op.clickable=op.clickable:null;
defined(op.visible) ?_op.visible=op.visible:null;
defined(op.zIndex) ?_op.zIndex=op.zIndex:null;
if(["polygon","polyline","rectangle","circle"].indexOf(type)!== -1 ){
defined(op.strokeColor) ?_op.strokeColor=op.strokeColor:null;
defined(op.strokeOpacity) ?_op.strokeOpacity=op.strokeOpacity:null;
defined(op.strokeWeight) ?_op.strokeWeight=op.strokeWeight:null;
}
if(["polygon","rectangle","circle"].indexOf(type)!== -1 ){
defined(op.fillColor) ?_op.fillColor=op.fillColor:null;
defined(op.fillOpacity) ?_op.fillOpacity=op.fillOpacity:null;
}
if(["polygon","polyline"].indexOf(type)!== -1 ){
defined(op.geodesic) ?_op.geodesic=op.geodesic:null;
}
if(type == "marker"){
defined(op.animation) ?_op.animation=op.animation:null;
defined(op.cursor) ?_op.cursor=op.cursor:null;
defined(op.draggable) ?_op.draggable=op.draggable:null;
defined(op.flat) ?_op.flat=op.flat:null;
defined(op.icon) ?_op.icon=op.icon:null;
defined(op.optimized) ?_op.optimized=op.optimized:null;
defined(op.position) ?_op.position=op.position:null;
defined(op.raiseOnDrag) ?_op.raiseOnDrag=op.raiseOnDrag:null;
defined(op.shadow) ?_op.shadow=op.shadow:null;
defined(op.shape) ?_op.shape=op.shape:null;
defined(op.title) ?_op.title=op.title:null;
}
switch(type){
case "polygon" :
return new google.maps.Polygon(_op);
break;
case "rectangle" :
return new google.maps.Rectangle(_op);
break;
case "circle" :
return new google.maps.Circle(_op);
break;
case "polyline" :
return new google.maps.Polyline(_op);
break;
case "marker" :
return new google.maps.Marker(_op);
break;
};
}
現在很奇怪,這不起作用,但它正確地擊中所有斷點,當我檢查它時,它似乎很好。它只是不返回谷歌地圖元素..再次頂端代碼塊(功能create_map_element3)確實工作..
好吧,在堆棧中說,但沒有任何反應,似乎沒有谷歌得到它。就像它之間有一些以太之類的東西就會迷路了。我檢查返回的中斷點,並按預期填充_op,看起來好像新的google.maps.Polygon(_op);火災的權利...不是100%在這個atm – 2012-03-02 21:59:43
那麼,這是真的比我最近的建議^^ – 2012-03-05 22:46:26
兩個反對呢? @Dr。 Molle,你在開玩笑嗎?對不起,我不這麼認爲。我會這樣認爲,因爲你之前基於orginals開發過,編輯沒有太大差別,這次我粘貼了這個東西。 – 2012-03-06 01:04:22