Skip to content

Commit

Permalink
add center option #6
Browse files Browse the repository at this point in the history
  • Loading branch information
morontt committed Nov 17, 2016
1 parent 8feffb6 commit 789fcb9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ OR via yii params configuration. For example:
],
```

To get key, please visit [options page](https://code.google.com/apis/console/)
To get key, please visit [page](https://developers.google.com/maps/documentation/javascript/get-api-key)

Google Maps Options
-------------------
Expand Down
18 changes: 12 additions & 6 deletions assets/googlemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,21 @@ yii.googleMapManager = (function ($) {
pub.bounds.extend(position);
var marker = new google.maps.Marker({
map: pub.map,
position: position,
position: position
});
bindInfoWindow(marker, pub.map, pub.infoWindow, htmlContent);
pub.markerClusterer.addMarker(marker);
pub.markers.push(marker);
if (pub.nextAddress == pub.geocodeData.length) {
pub.map.fitBounds(pub.bounds);
if (pub.map.getZoom() > 17) {
pub.map.setZoom(17);
if (pub.userOptions.mapOptions.center) {
pub.map.setCenter(pub.mapOptions.center);
} else {
google.maps.event.addListenerOnce(pub.map, 'bounds_changed', function () {
if (pub.map.getZoom() > 17) {
pub.map.setZoom(17);
}
});
pub.map.fitBounds(pub.bounds);
}
}
}
Expand All @@ -132,6 +138,7 @@ yii.googleMapManager = (function ($) {
pub.nextAddress = 0;
pub.zeroResult = 0;
pub.markers = [];
pub.userOptions = options;
$.extend(true, pub, options);
deferred.resolve();

Expand Down Expand Up @@ -196,5 +203,4 @@ yii.googleMapManager = (function ($) {
}

return pub;
})
(jQuery);
})(jQuery);
5 changes: 5 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
{
"name": "Dmitry Semenov",
"email": "[email protected]"
},
{
"name": "Alexander Harchenko",
"email": "[email protected]",
"homepage": "https://morontt.info"
}
],
"require": {
Expand Down

0 comments on commit 789fcb9

Please sign in to comment.