# m\_geomap

Source: https://zotonic.com/docs/2771/m_geomap

URI: https://zotonic.com/id/2771

Language: en



Expose GeoMap configuration and country-map data to templates and model GET requests.

Model paths
-----------

| Path             | Result                                                      |
| ---------------- | ----------------------------------------------------------- |
| `provider`       | Configured map provider.                                    |
| `google_api_key` | Configured Google Maps API key.                             |
| `location_lat`   | Configured initial latitude.                                |
| `location_lng`   | Configured initial longitude.                               |
| `zoomlevel`      | Configured initial zoom.                                    |
| `countries`      | Country GeoJSON enriched with visible country resources.    |
| `nearby`         | Empty map; resource lookup is not implemented on this path. |
| `locations`      | Empty map; resource lookup is not implemented on this path. |

Configuration reads return the stored `mod_geomap` value without a model-level fallback. Templates choose their own defaults, for example:

```django
{{ m.geomap.location_lat|default:0 }}
```

These reads have no administrator-only ACL check, including `google_api_key`. Unknown paths return `{error, unknown_path}`. GET model callbacks return `{ok, {Value, Rest}}`, retaining unused path segments.

Country data
------------

`countries` reads `priv/data/internet_users_2005_choropleth_lowres.json` from the `zotonic_mod_geomap` application. The decoded geometry is cached in the site's depcache for one day, or until the cache is flushed. Resource values and visibility checks are applied separately on every request. No copy in the site directory is needed. After replacing the data file, flush the site's depcache to load the new geometry immediately.

The model searches up to 1,000 resources in category `country`, checks their visibility, and groups them by `address_country`. It combines their IDs and titles with `map_color` and `map_value` for matching country features. Missing colors default to `#ccc`, and missing values to an empty binary. If the category does not exist, no resource values are added. Sint Maarten's `sx` country code is grouped with Saint Martin's `mf` geometry.

For nearby resource queries, use the `geo_nearby` search supplied by `mod_geomap`; the `nearby` and `locations` model paths do not implement that search.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/2771?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/2771?language=en>)
