Skip to content

How to check if location is within bounds #9

@anchetaWern

Description

@anchetaWern

Thank you for this library.

Not sure if it's possible, but can this library be used to check if a location is within specific bounds? Something like this:

function latLng($arr) {
    return new Biscolab\GoogleMaps\Object\LatLng([
      Biscolab\GoogleMaps\Fields\LatLngFields::LAT => $arr['lat'],
      Biscolab\GoogleMaps\Fields\LatLngFields::LNG => $arr['lng']
    ]);
  }


$bounds = new Biscolab\GoogleMaps\Object\LatLngBounds();
$bounds->extend(latLng([
  "lat" => 132334323,
  "lng" => 112143432
]));

$place = latLng([
  "lat" => 133434323
  "lng" => 5352523
]);

print_r($bounds->getCenter());
print_r($bounds->contains($place));

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions