最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to open Google Map in another tab with your coordinates in JavaScript? - Stack Overflow

programmeradmin5浏览0评论

I have coordinates in a text box with a button. I am trying to take my coordinates from the text box and concatenate with the google maps. I do not want to show any map or something on my website. I just want to take my coordinates from the text box and open map in new tab with coordinates. My current logic:

var coordinates = $('#coordinates').val();
var url = "/"+ coordinates +",12.21z?hl=en"

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

Modification: I want to show something like this with marker:

and It showing this:

I have coordinates in a text box with a button. I am trying to take my coordinates from the text box and concatenate with the google maps. I do not want to show any map or something on my website. I just want to take my coordinates from the text box and open map in new tab with coordinates. My current logic:

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

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

Modification: I want to show something like this with marker:

and It showing this:

Share Improve this question edited Jun 14, 2017 at 7:28 Armaan Labib asked Jun 14, 2017 at 7:13 Armaan LabibArmaan Labib 1651 gold badge2 silver badges16 bronze badges 2
  • what's not working with the above code? – Deblaton Jean-Philippe Commented Jun 14, 2017 at 7:15
  • The problem is its not showing marker in map? – Armaan Labib Commented Jun 14, 2017 at 7:24
Add a ment  | 

1 Answer 1

Reset to default 7
var coordinates, url;

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

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

For zooming you need to play with these values:

发布评论

评论列表(0)

  1. 暂无评论