2012年5月9日 星期三

取得 google map 的坐標方法2

不知為何, google map API 輸入地址都會定到錯誤的地點, 所以改使用坐標來定位, 取得google map 定位點坐標(latitude + longitude)的方法之一參考看看下列3個步驟.


步驟1:  在 google map 上任何一個地方按右鍵, 選取 "這裡有什麼?" 按完之後畫面就會多出一個綠色小箭頭.



步驟2: 滑鼠移到(on mouse over) 產生出來的綠色小箭頭就會看到坐標.


步驟3: 點一下(on click) 產生出來的綠色小箭頭, 就會彈出這個對話框, 裡頭有街景和坐標.

取得google map 定位點坐標(latitude + longitude)的方法之一

不知為何, google map API 輸入地址都會定到錯誤的地點, 所以改使用坐標來定位, 取得google map 定位點坐標(latitude + longitude)的方法之一參考看看下列3個步驟.


步驟1: 到 google map 輸入 keyword 找到一個坐標.
說明: 按下右邊的標題的超連結, 右邊google map 就會彈出一個對話框, 選取框框裡的 "更多資訊" -- "傳送".


步驟2: 在傳送的框框裡, 會有一個超連結, 用 "複製超連結" 或 "連結另開新視窗", 就可以看到定位點.



步驟3: 成功取得坐標.


說明: 複製出來的網址, URL:
http://maps.google.com.tw/maps?f=q&source=s_q&hl=zh-TW&geocode=&q=Riparian+Plaza&aq=&sll=-27.468183,153.030109&sspn=0.001323,0.002041&vpsrc=0&brcurrent=3,0x0:0x0,0&ie=UTF8&ll=-27.468466,153.030831&spn=0.002059,0.003484&t=m&z=19&iwloc=A&cid=839265525257578925

2012年5月8日 星期二

指定 google map 的 button 和地名 用的語系(language)

在預設, 沒有指定語系的情況下, google map API 會自動判斷 user os 正在使用中的語系, 來輸出 button 的 label 和 地名, 我覺得很合理, 這個情況下就可以會產生下列的畫面:
說明: 在英文版的畫面中, 出現 中文字的 "地圖",  會出現中文字是因為 user 使用中文的 OS.

解決的辦法是在引用 google api 的 js 時, 增加 language 參數即可, 例如:
type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&language=en"

跑出來的畫面如下:
說明: 中文版 button 寫 地圖, 英文版 button 寫 Map

2012年4月25日 星期三

google chrome 遇到 javascript 的 new XMLDocument()相容性有問題

今天有一個系統, 使用 ajax 做2個下拉框的聯動. 原始碼如下:
var oXML = new XMLDocument(xURI, function() {
 ....
 }); 

發現上面的寫法似乎只有google chrome 會出錯,所以改寫成下列的寫法:
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET", xURI, false);
xmlhttp.send(null);
var xmlDoc = xmlhttp.responseXML;
...


結論: 增加一個 browser 的判斷 ie/non-ie 就解決了. 也許也可以用 jQuery 來試看看, 反正是小功能, 可以正常跑出結果就好了.

2012年4月16日 星期一

C# upload file runat client 的範例

網路上 runat=server 的範例太多,
今天學習的進度是,c#上傳檔案,不是透過runat="server" 的寫法.:

using System.IO;


public bool UploadFileCollection()
{
bool returnValue=false;
string uploadPath=GetFileUploadPath() + "\\";
try
{
//HTTP Context to get access to the submitted data
HttpContext postedContext = HttpContext.Current;
//File Collection that was submitted with posted data
HttpFileCollection Files = postedContext.Request.Files;

HttpFileCollection uploadFiles = Request.Files;
for (int i = 0; i < Files.Count; i++)
{
HttpPostedFile postedFile = Files[i];

// Access the uploaded file's content in-memory:
System.IO.Stream inStream = postedFile.InputStream;
byte[] fileData = new byte[postedFile.ContentLength];
inStream.Read(fileData, 0, postedFile.ContentLength);

// Save the posted file in our "data" virtual directory.
//postedFile.SaveAs(uploadPath + postedFile.FileName);
string filename;
filename = String.Format("{0}{1}", Guid.NewGuid().ToString("N"), Path.GetExtension(postedFile.FileName));
postedFile.SaveAs(uploadPath + filename);

// Also, get the file size and filename (as specified in
// the HTML form) for each file:
Response.Write("<li>" + postedFile.FileName + ": " + postedFile.ContentLength.ToString() + " bytes</li>");
returnValue=true;
}
}
catch (Exception ex1)
{
throw new Exception("Problem uploading file: " + ex1.Message);
}

return returnValue;
}

2012年4月2日 星期一

萬一你的系統使用了 WebDB3 元件, 可是主機無法註冊COM+元件

萬一你的系統使用了 WebDB3 元件, 可是執行環境的主機無法註冊COM+元件, 或是元件裝的上去可是沒有作用, 該怎麼辦?


客戶主機: Win2008 R2 (64位元) + IIS 7.5



無法安裝的畫面:



結論:
把那一堆呼叫 webDB3 的程式碼修改回來使用傳統寫法.

Classic ASP Script Error Messages No Longer Shown in Web Browser by Default

結論: 要看到錯誤訊息, 要先在 IIS 7 裡的 "ASP" 設定 "將錯誤傳送到瀏覽器" 為 True, 並且在 "錯誤網頁" 裡設定 "顯示詳細錯誤".


In earlier versions of IIS, error messages from classic ASP scripts were sent to a Web browser, by default. Because these error messages might reveal sensitive information to malicious users, IIS 7 disables this feature by default. When your classic ASP scripts encounter an error in IIS 7, you receive the following error message by default:

An error occurred on the server when processing the URL. Please contact the system administrator.

If you are the system administrator please click here to find out more about this error.

You can customize the ASP script error message, and also determine whether to return the script errors to a Web browser. Note: As a best practice for security, you should only enable sending ASP script error messages to a Web browser on a development or test computer; returning script error messages to a Web browser can unintentionally expose more information than you intended to show.

Working with User Access Control

You need to make sure that you follow the steps in this document by using an account that has full administrative permissions. This is best accomplished by using one of two methods:

  • Log in to your computer by using the local administrator account.
  • If you are logged in using an account with administrative permissions but that is not the local administrator account, open all applications and all command prompt sessions by using the "Run as Administrator" option.

These above conditions are required because the User Account Control (UAC) security component in Windows Vista and Windows Server 2008 will prevent administrative access to IIS 7’s configuration settings. For more information about UAC, see the following documentation:

Customizing Classic ASP Error Messages

The configuration settings that you use to customize these settings are in the following list:

scriptErrorMessage
This is an optional string attribute that specifies the error message that will be sent to the browser when specific debugging errors are not sent to the client.
scriptErrorSentToBrowser
This is an optional Boolean attribute that specifies whether the writing of debugging specifics to the client browser is enabled.

You can configure these settings by using IIS Manager. To do so, open IIS Manager and navigate to the site or application where you want to enable or disable script messages, and then double-click the ASP feature.

In the list of ASP features, configure the Script Error Message and Send Errors To Browser options.

You can also configure these settings by using the command-line tool AppCmd.exe with the following syntax:

appcmd.exe set config "Default Web Site" -section:system.webServer/asp /scriptErrorMessage:"An error occurred."
appcmd.exe set config "Default Web Site" -section:system.webServer/asp /scriptErrorSentToBrowser:"False"

More Information

For additional information about the options that are available for classic ASP debugging, see the following page in the IIS configuration reference on the Microsoft IIS.net Web site:

http://www.iis.net/ConfigReference/system.webServer/asp

As an alternative to returning ASP script error messages to a Web browser, you can enable Failed Request Tracing on your server. For example, you could add a rule to trace HTTP 500 errors automatically, which the ASP engine generates when an error occurs. By analyzing the output in the Failed Request Tracing logs on your server, you can pinpoint the source of classic ASP errors. As an additional security note, Failed Request Tracing logs are not available to Web browsers, so the troubleshooting information is only available on your server. If you use Failed Request Tracing, it will also let you troubleshoot unmonitored classic ASP errors in detail without having to reproduce the errors.

Facebook 留言板