0

嗨,大家好我与下面这段代码的工作,但我不知道是标志是可能 和我可怎么办添加更多的一个标志,并设置其他DIV显示此位置。 任何人都知道我能做些什么,或者给我一个提示谷歌地图两个在一个地图

及其对视觉工作室

angular.module('app', ['onsen']). 
    directive('myMap', function() { 
     // directive link function 
     var link = function (scope, element, attrs) { 
      var map, infoWindow; 
      var markers = []; 

      // map config 
      var mapOptions = { 
       center: new google.maps.LatLng(-29.3130754, -50.8542323), 
       zoom: 11, 
       mapTypeId: google.maps.MapTypeId.ROADMAP, 
       scrollwheel: false 
      }; 

      // init the map 
      function initMap() { 
       if (map === void 0) { 
        map = new google.maps.Map(element[0], mapOptions); 
       } 
      } 

      // place a marker 
      function setMarker(map, position, title, content) { 
       var marker; 
       var markerOptions = { 
        position: position, 
        map: map, 
        title: title, 
        icon: 'images/Maps/blue-dot.png' 
       }; 

       marker = new google.maps.Marker(markerOptions); 
       markers.push(marker); // add marker to array 

       google.maps.event.addListener(marker, 'click', function() { 
        // close window if not undefined 
        if (infoWindow !== void 0) { 
         infoWindow.close(); 
        } 
        // create new window 
        var infoWindowOptions = { 
         content: content 
        }; 
        infoWindow = new google.maps.InfoWindow(infoWindowOptions); 
        infoWindow.open(map, marker); 
       }); 
      } 

      // show the map and place some markers 
      initMap(); 

      setMarker(map, new google.maps.LatLng(-29.3130754, -50.8542323), 'adress'); 

     }; 

     return { 
      restrict: 'A', 
      template: '<div id="gmaps"></div>', 
      replace: true, 
      link: link 
     }; 
    }); 

回答

1

这里,科尔多瓦的应用是在谷歌地图中添加多个标记的方式,U盘只需要其中包含数组您所需的纬度经度值。

var myLatLng = {lat: -25.363, lng: 131.044}; 

    var map = new google.maps.Map(document.getElementById('map'), { 
     zoom: 4, 
     center: myLatLng 
    }); 

    var marker = new google.maps.Marker({ 
     position: myLatLng, 
     map: map, 
     title: 'Hello World!' 
    }); 
    var myLatLng1={lat: -25.163, lng: 131.644}; 
    var marker2 = new google.maps.Marker({ 
     position: myLatLng1, 
     map: map, 
     title: 'Hello World!' 
    }); 

你也可以有一个数组,其中包含数据元素conataining latutude和经度值。

 for (var i = 0; i < locations.length; i++) { //Your location contains the lat long position 
     var marker = new google.maps.Marker({ 
     position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
     map: map, 
     title: 'Hello World!' 
     });