Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌地图标记url_Javascript_Google Maps - Fatal编程技术网

Javascript 谷歌地图标记url

Javascript 谷歌地图标记url,javascript,google-maps,Javascript,Google Maps,有人能帮忙吗。我有以下代码,但当我单击标记时,它会将我重定向到同一页面: <script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script> <script type="text/javascript"> function initialize() { var myOptions = { zoom: 14, cent

有人能帮忙吗。我有以下代码,但当我单击标记时,它会将我重定向到同一页面:

<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>

<script type="text/javascript"> 
function initialize() {
  var myOptions = {
    zoom: 14,
    center: new google.maps.LatLng(<?php echo $latitude; ?>, <?php echo $longitude; ?>),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    streetViewControl: true,
    scrollwheel: false
  }

  var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);

  for (var i = 0; i < locations.length; i++) {
      var image = new google.maps.MarkerImage('images/greenmarkers/'+ i +'.png');
      var location = locations[i];
      var myLatLng = new google.maps.LatLng(location[1], location[2]);
      var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          icon: image,
          title: location[0],
          url: location[3]
      });


google.maps.event.addListener(marker, 'click', function() {
  window.location.href = marker.url;
});
  }
}
</script>

<script type="text/javascript"> 
var locations = [['test', 63.3740200000000, 19.6301320000000, 'http://www.test.com'],['test1', 63.3725155758185, 19.6264879703522, 'http://www.test1.com'],['test2', 63.3762550022764, 19.6305649280548, 'http://www.test2.com']];
</script> 

函数初始化(){
变量myOptions={
缩放:14,
中心:新google.maps.LatLng(,),
mapTypeId:google.maps.mapTypeId.ROADMAP,
街景控制:对,
滚轮:错误
}
var map=new google.maps.map(document.getElementById('map_canvas'),myOptions);
对于(变量i=0;i
以下是一个工作代码:

function loadURL(marker) {
    return function () {
        window.location.href = marker.url;
    }
}

function initialize() {
  var myOptions = {
    zoom: 5,
    center: new google.maps.LatLng(50.00, 50.00),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    streetViewControl: true,
    scrollwheel: false
  }

  locations=[["aaa",51.00, 51.00, "http://www.atoztoa.com"], ["bbb",52.00, 52.00, "http://www.google.com"]];

  var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);

  for (var i = 0; i < locations.length; i++) {
      var image = new google.maps.MarkerImage('roundedbutton1.png');
      var location = locations[i];
      var myLatLng = new google.maps.LatLng(location[1], location[2]);
      var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          icon: image,
          title: location[0],
          url: location[3]
      });

        google.maps.event.addListener(marker, 'click', loadURL(marker));
  }
}
函数加载URL(标记){
返回函数(){
window.location.href=marker.url;
}
}
函数初始化(){
变量myOptions={
缩放:5,
中心:新google.maps.LatLng(50.00,50.00),
mapTypeId:google.maps.mapTypeId.ROADMAP,
街景控制:对,
滚轮:错误
}
位置=[“aaa”,51.00,51.00http://www.atoztoa.com“],[“bbb”,52.00,52.00,”http://www.google.com"]];
var map=new google.maps.map(document.getElementById('map_canvas'),myOptions);
对于(变量i=0;i
以下是一个工作代码:

function loadURL(marker) {
    return function () {
        window.location.href = marker.url;
    }
}

function initialize() {
  var myOptions = {
    zoom: 5,
    center: new google.maps.LatLng(50.00, 50.00),
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    streetViewControl: true,
    scrollwheel: false
  }

  locations=[["aaa",51.00, 51.00, "http://www.atoztoa.com"], ["bbb",52.00, 52.00, "http://www.google.com"]];

  var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);

  for (var i = 0; i < locations.length; i++) {
      var image = new google.maps.MarkerImage('roundedbutton1.png');
      var location = locations[i];
      var myLatLng = new google.maps.LatLng(location[1], location[2]);
      var marker = new google.maps.Marker({
          position: myLatLng,
          map: map,
          icon: image,
          title: location[0],
          url: location[3]
      });

        google.maps.event.addListener(marker, 'click', loadURL(marker));
  }
}
函数加载URL(标记){
返回函数(){
window.location.href=marker.url;
}
}
函数初始化(){
变量myOptions={
缩放:5,
中心:新google.maps.LatLng(50.00,50.00),
mapTypeId:google.maps.mapTypeId.ROADMAP,
街景控制:对,
滚轮:错误
}
位置=[“aaa”,51.00,51.00http://www.atoztoa.com“],[“bbb”,52.00,52.00,”http://www.google.com"]];
var map=new google.maps.map(document.getElementById('map_canvas'),myOptions);
对于(变量i=0;i
看起来像是。请参阅,了解修复它的基本方法。谢谢Matt。我试过了,但运气不好。看起来像。请参阅,了解修复它的基本方法。谢谢Matt。我试过了,但没有成功。