You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.
I need to render polygons on google maps using this library.
I store my cordinateds as geomtry data type on postgis postgres [https://postgis.net/docs/geometry.html]. So my coordinates are not a human readable latlong array. Geometry data type cannot be handle due this library recieves arrays to define polygons
`$coords = [
new LatLng(['lat' => 25.774252, 'lng' => -80.190262]),
new LatLng(['lat' => 18.466465, 'lng' => -66.118292]),
new LatLng(['lat' => 32.321384, 'lng' => -64.75737]),
];
I solved a similar issue when generating polylines.
Model:
public function getLine($rp_zone)
{
return Map::findBySQL("
SELECT
ST_Y((dp).geom) AS lat,
ST_X((dp).geom) AS lng,
ST_Y(centre) AS centre_lat,
ST_X(centre) AS centre_lng
FROM (
SELECT ST_DumpPoints(geom) AS dp,
ST_Centroid(geom) AS centre
FROM traffic.map
WHERE rp_zone = :rp_zone
)x
",[':rp_zone' => $rp_zone])->asArray()->all();
}
Controller:
public function actionView($id)
{
return $this->render('view', [
'model' => $model = $this->findModel($id),
]);
}
View:
$coord = new LatLng([
'lat' => $model->map->getLine($model->zone_id)[0]['centre_lat'],
'lng' => $model->map->getLine($model->zone_id)[0]['centre_lng']
]);
$map = new Map([
'center' => $coord,
'zoom' => 20,
]);
foreach ($model->map->getLine($model->zone_id) as $coord) {
$coords[] = new LatLng(['lat' => $coord['lat'], 'lng' => $coord['lng']]);
}
$polyline = new Polyline([
'path' => $coords,
]);
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I need to render polygons on google maps using this library.
I store my cordinateds as geomtry data type on postgis postgres [https://postgis.net/docs/geometry.html]. So my coordinates are not a human readable latlong array. Geometry data type cannot be handle due this library recieves arrays to define polygons
`$coords = [
new LatLng(['lat' => 25.774252, 'lng' => -80.190262]),
new LatLng(['lat' => 18.466465, 'lng' => -66.118292]),
new LatLng(['lat' => 32.321384, 'lng' => -64.75737]),
];
Geometry data type has different data type outputs https://postgis.net/docs/reference.html#Geometry_Outputs.
One of that outputs is GeoJSON https://postgis.net/docs/ST_AsGeoJSON.html. That actually google maps api can manage according with google's api doc https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson
How can I handle this type of data to yii2-google-maps-library???
The text was updated successfully, but these errors were encountered: