Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to check if location is within bounds #9

Open
anchetaWern opened this issue Sep 13, 2020 · 1 comment
Open

How to check if location is within bounds #9

anchetaWern opened this issue Sep 13, 2020 · 1 comment
Labels

Comments

@anchetaWern
Copy link

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));
@SaintPeter
Copy link

@anchetaWern This library may provide what you're looking for:
https://github.com/alexpechkarev/geometry-library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants