2015-06-04 20 views
5

मैं कोणीय-google-नक्शे उपयोग कर रहा हूँ पर गतिशील शीर्षक और वर्णन को दिखाने के लिए कैसे, HTML कोड इस प्रकारकोणीय-google-नक्शे: मार्कर

<ui-gmap-google-map center='mapData.map.center' zoom='mapData.map.zoom' 
    events="mapEvents"> 
    <ui-gmap-markers models="mapData.map.markers" coords="'self'"> 
    </ui-gmap-markers> 
    </ui-gmap-google-map> 

JS में इस प्रकार

angular.extend(this, $controller('MapsMixinController', 
{$scope:$scope, map:mapData.data[0].map})); 

MapsMixinController बुला । जेएस कोड से इस नियंत्रक को बुलाओ। चिह्नित करने के लिए सक्षम क्लिक पर मार्कर & दिखा रहे हैं।

MapsMixinController.js

/** 
* Controller providing common behaviour for the other map controllers 
*/ 
angular 
    .module('app') 
    .controller('MapsMixinController', ['$scope', 'GeolocationService', 'uiGmapGoogleMapApi', 'map', 
     function($scope, GeolocationService, GoogleMapApi, map) { 
      var _this = this; 

      $scope.mapEvents = { 
       click: function(mapModel, eventName, originalEventArgs) { 
        var e = originalEventArgs[0]; 
        if (e.latLng) { 
         $scope.mapData.map.markers.push({ 
          id: new Date().getTime(), 
          latitude: e.latLng.lat(), 
          longitude: e.latLng.lng() 
         }); 
         // This event is outside angular boundary, hence we need to call $apply here 
         $scope.$apply(); 
        } 
       } 
      }; 

      // Returns a default map based on the position sent as parameter 
      this.getDefaultMap = function(position) { 
       return { 
        markers: [], 
        center: { 
         latitude: position.coords.latitude, 
         longitude: position.coords.longitude 
        }, 
        zoom: 14 
       }; 
      }; 

      // Initialize the google maps api and configure the map 
      GoogleMapApi.then(function() { 
       GeolocationService().then(function(position) { 
        $scope.mapData.map = map || _this.getDefaultMap(position); 
       }, function() { 
        $scope.error = "Unable to set map data"; // TODO use translate 
       }); 
      }); 
     } 
    ]); 

मैं मार्करों पर माउस हॉवर पर शीर्षक कैसे दिखा सकते हैं? और मार्कर पर विवरण दिखाने के तरीके पर क्लिक करें?

+0

मुझे लगता है कि बस एक नया मार्कर के रूप में गूगल मैप्स एपीआई में कहा जोड़ रहा है: 'वर मार्कर = नए google.maps.Marker ({ स्थिति: myLatlng, नक्शा: नक्शा, शीर्षक: 'नमस्ते दुनिया! ' }); –

+0

https://developers.google.com/maps/documentation/javascript/markers –

+0

मेरा मतलब है कि केवल अपने मार्कर ऐरे में शीर्षक जोड़ना, फिर Google नक्शे एपीआई इसे समझेंगे –

उत्तर

2

मार्कर डेटा बनाते समय आप अक्षांश और देशांतर संपत्ति के साथ अकेले शीर्षक संपत्ति जोड़ सकते हैं।

/** 
* Controller providing common behaviour for the other map controllers 
*/ 
angular 
    .module('app') 
    .controller('MapsMixinController', ['$scope', 'GeolocationService', 'uiGmapGoogleMapApi', 'map', 
     function($scope, GeolocationService, GoogleMapApi, map) { 
      var _this = this; 

      $scope.mapEvents = { 
       click: function(mapModel, eventName, originalEventArgs) { 
        var e = originalEventArgs[0]; 
        if (e.latLng) { 
         $scope.mapData.map.markers.push({ 
          id: new Date().getTime(), 
          latitude: e.latLng.lat(), 
          longitude: e.latLng.lng(), 
          title: "Mouse over text" 
         }); 
         // This event is outside angular boundary, hence we need to call $apply here 
         $scope.$apply(); 
        } 
       } 
      }; 

      // Returns a default map based on the position sent as parameter 
      this.getDefaultMap = function(position) { 
       return { 
        markers: [], 
        center: { 
         latitude: position.coords.latitude, 
         longitude: position.coords.longitude 
        }, 
        zoom: 14 
       }; 
      }; 

      // Initialize the google maps api and configure the map 
      GoogleMapApi.then(function() { 
       GeolocationService().then(function(position) { 
        $scope.mapData.map = map || _this.getDefaultMap(position); 
       }, function() { 
        $scope.error = "Unable to set map data"; // TODO use translate 
       }); 
      }); 
     } 
    ]); 
+1

साथिश, आपका प्लंकर "मार्कर" नहीं है "मार्कर"। उत्तर में से कोई भी हल नहीं करता है कि "मार्कर" में प्रत्येक मार्कर के लिए एक अलग शीर्षक कैसे दिखाया जाए –

संबंधित मुद्दे