Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Allow specifying info windows and custom icons #14

Merged
merged 1 commit into from Feb 28, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/angular-google-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@
_handlers = [], // event handlers
_windows = [], // InfoWindow objects
o = angular.extend({}, _defaults, opts),
that = this;
that = this,
currentInfoWindow = null;

this.center = opts.center;
this.zoom = o.zoom;
Expand Down Expand Up @@ -178,7 +179,7 @@
});
};

this.addMarker = function (lat, lng, label, url,
this.addMarker = function (lat, lng, icon, infoWindowContent, label, url,
thumbnail) {

if (that.findMarker(lat, lng) != null) {
Expand All @@ -187,7 +188,8 @@

var marker = new google.maps.Marker({
position: new google.maps.LatLng(lat, lng),
map: _instance
map: _instance,
icon: icon
});

if (label) {
Expand All @@ -197,6 +199,20 @@
if (url) {

}

if (infoWindowContent != null) {
var infoWindow = new google.maps.InfoWindow({
content: infoWindowContent
});

google.maps.event.addListener(marker, 'click', function() {
if (currentInfoWindow != null) {
currentInfoWindow.close();
}
infoWindow.open(_instance, marker);
currentInfoWindow = infoWindow;
});
}

// Cache marker
_markers.unshift(marker);
Expand All @@ -206,6 +222,8 @@
"lat": lat,
"lng": lng,
"draggable": false,
"icon": icon,
"infoWindowContent": infoWindowContent,
"label": label,
"url": url,
"thumbnail": thumbnail
Expand Down Expand Up @@ -438,7 +456,7 @@

angular.forEach(newValue, function (v, i) {
if (!_m.hasMarker(v.latitude, v.longitude)) {
_m.addMarker(v.latitude, v.longitude);
_m.addMarker(v.latitude, v.longitude, v.icon, v.infoWindow);
}
});

Expand Down