Skip to content

Commit

Permalink
Bug Fix
Browse files Browse the repository at this point in the history
Fixed issue with entries with more than 1 marker not sorting by distance correctly.
Fixed issue with entries with more than 1 marker returning data outside the range of the specified distance.
Fixed issue with current location tag causing the map to reset when location has changed.
  • Loading branch information
objectivehtml committed Feb 23, 2016
1 parent e58ce49 commit a054d9d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
12 changes: 12 additions & 0 deletions fieldtypes/GoogleMaps_GoogleMapFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ public function modifyElementsQuery(DbCommand $query, $params = array())

$this->queryParams = array_merge($defaultParams, $params);

if(isset($this->queryParams['latitude']))
{
$this->queryParams['lat'] = $this->queryParams['latitude'];
unset($this->queryParams['latitude']);
}

if(isset($this->queryParams['longitude']))
{
$this->queryParams['lng'] = $this->queryParams['longitude'];
unset($this->queryParams['longitude']);
}

$handle = $this->model->handle;

if(isset($this->queryParams['address']))
Expand Down
10 changes: 6 additions & 4 deletions models/GoogleMaps_MapDataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ public function getMarkers()
$marker = GoogleMaps_MarkerModel::populateModel((array) $marker);
}

if($this->queryParams)
if($this->queryParams && $marker->isWithinProximity($this->queryParams))
{
$marker->isWithinProximity($this->queryParams);
$return[] = $marker;
}
else if (!$this->queryParams)
{
$return[] = $marker;
}

$return[] = $marker;
}

if($this->queryParams)
Expand Down
23 changes: 18 additions & 5 deletions resources/js/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ var GoogleMaps = {
return this.api.getBounds();
},

getCenter: function() {
return this.api.getCenter();
},

getDiv: function() {
return this.api.getDiv();
},
Expand Down Expand Up @@ -1107,8 +1111,6 @@ var GoogleMaps = {
},

updateMarkerIcons: function() {
var t = this;

_.each(this.getMarkers(), function(marker, i) {
if(i < t.getMarkers().length - 1) {
var icon = 'http://mt.google.com/vt/icon/text='+String.fromCharCode(65 + i)+'&psize=16&font=fonts/arialuni_t.ttf&color=ff330000&name=icons/spotlight/spotlight-waypoint-a.png&ax=44&ay=48&scale=2';
Expand All @@ -1117,10 +1119,10 @@ var GoogleMaps = {
var icon = 'http://mt.google.com/vt/icon/text='+String.fromCharCode(65 + i)+'&psize=16&font=fonts/arialuni_t.ttf&color=ff330000&name=icons/spotlight/spotlight-waypoint-b.png&ax=44&ay=48&scale=2';
}

t.getLocation(i).icon = icon;
this.getLocation(i).icon = icon;

marker.setIcon(icon);
});
}, this);
},

directionsRequest: function(callback) {
Expand Down Expand Up @@ -1434,8 +1436,15 @@ var GoogleMaps = {

markerOptions: {},

positionOptions: {
enableHighAccuracy: true,
maximumAge: 1000
},

map: false,

hasSetBounds: false,

constructor: function(map, options) {
this.map = map;

Expand All @@ -1446,7 +1455,10 @@ var GoogleMaps = {

this.base(options);

console.log(this.positionOptions);

this.api = new GeolocationMarker(this.map.api, this.circleOptions, this.markerOptions);
this.setPositionOptions(this.positionOptions);

this.bindEvents();
},
Expand Down Expand Up @@ -1516,9 +1528,10 @@ var GoogleMaps = {
onGeolocationError: function() {},

onPositionChanged: function() {
if(this.fitBounds) {
if(this.fitBounds && !this.hasSetBounds) {
this.map.bounds.extend(this.getPosition());
this.map.fitBounds(this.map.bounds);
this.hasSetBounds = true;
}
}

Expand Down

0 comments on commit a054d9d

Please sign in to comment.