2017-06-14 24 views
-1

我有一個按鈕的文本框中的座標。我試圖從文本框中取出我的座標並與谷歌地圖連接。我不想在我的網站上顯示任何地圖或其他內容。我只想從文本框中取出我的座標,然後在帶有座標的新選項卡中打開地圖。我目前的邏輯:如何使用JavaScript中的座標在另一個選項卡中打開Goog​​le地圖?

var coordinates = $('#coordinates').val(); 
var url = "https://www.google.com.sa/maps/"+ coordinates +",12.21z?hl=en" 

$("#map").on('click', function() { 
     window.open(url, '_blank'); 
}); 

修改: 我要顯示這樣的事情與標記:

enter image description here

和它呈現這樣的:enter image description here

+0

什麼不符合上述代碼? –

+0

問題是它沒有在地圖上顯示標記? –

回答

1
var coordinates, url; 

$("#map").on('click', function() { 
    coordinates = $('#coordinates').val(); 
    url   = "https://www.google.com.sa/maps/search/"+ coordinates +",12.21z?hl=en"; 

    window.open(url, '_blank'); 
}); 

對於縮放你需要玩這些值: enter image description hereenter image description here

+0

試試這個網址:https://www.google.com.sa/maps/search/500,500,12.21z – DazDylz

+0

那麼在搜索中會有我的座標嗎?我在哪裏放我的座標? –

+0

google.com.sa/maps/search/[here],[and here],12.21z – DazDylz

相關問題