LocationVendorGoogle
Reference for the LocationVendorGoogle module: render Google static map URLs from a location, and convert location coordinate, address and marker data objects into the Google Maps JSON and HTML attribute shapes a page needs.
This page is a pure reference. For how the framework fits together, see the Guide.
LocationVendorGoogleService- build Google static map URLs and convert location data to Google Maps JSON and HTML attributes.
LocationVendorGoogleService
Static functions that turn framework location data objects into the forms Google Maps uses: a static map image URL, JSON payloads, and HTML data attributes for coordinates, addresses and markers.
AddressToGoogleJson
LocationVendorGoogleService::AddressToGoogleJson(LocationAddressData $address): string
Convert a LocationAddressData to Google Maps JSON format.
| Name | Type | Description |
|---|---|---|
$address | LocationAddressData | The address to convert. |
Returns string The address as a JSON string.
AddressToHtmlAttributes
LocationVendorGoogleService::AddressToHtmlAttributes(LocationAddressData $address): string
Convert a LocationAddressData to HTML attributes for Google Maps.
| Name | Type | Description |
|---|---|---|
$address | LocationAddressData | The address to convert. |
Returns string A space-separated string of HTML data attributes.
CoordinateToGoogleJson
LocationVendorGoogleService::CoordinateToGoogleJson(LocationCoordinateData $coordinate): string
Convert a LocationCoordinateData to Google Maps JSON format, as lat and lng.
| Name | Type | Description |
|---|---|---|
$coordinate | LocationCoordinateData | The coordinate to convert. |
Returns string The coordinate as a JSON string with lat and lng keys.
CoordinateToHtmlAttributes
LocationVendorGoogleService::CoordinateToHtmlAttributes(LocationCoordinateData $coordinate): string
Convert a LocationCoordinateData to HTML attributes for Google Maps.
| Name | Type | Description |
|---|---|---|
$coordinate | LocationCoordinateData | The coordinate to convert. |
Returns string The latitude and longitude as HTML data attributes.
MarkerToHtmlAttributes
LocationVendorGoogleService::MarkerToHtmlAttributes(LocationMarkerData $marker): string
Convert a LocationMarkerData to HTML attributes for Google Maps.
| Name | Type | Description |
|---|---|---|
$marker | LocationMarkerData | The marker to convert. |
Returns string A space-separated string of HTML data attributes, including title and snippet when present.
MarkerToJavaScriptObject
LocationVendorGoogleService::MarkerToJavaScriptObject(LocationMarkerData $marker): string
Convert a LocationMarkerData to a JavaScript object for Google Maps.
| Name | Type | Description |
|---|---|---|
$marker | LocationMarkerData | The marker to convert. |
Returns string The marker as a JSON string, including title and snippet when present.
StaticMapUrl
LocationVendorGoogleService::StaticMapUrl(LocationData $location, int $width, int $height): string
Build a Google Maps static map image URL for a location, with a red marker on its coordinate. The Google API key is read from the Location module configuration.
| Name | Type | Description |
|---|---|---|
$location | LocationData | The location to map, whose coordinate centres the image. |
$width | int | The image width in pixels. |
$height | int | The image height in pixels. |
Returns string The static map image URL.