Gmaps (Google Maps) Data/Store locator 2.1.2
Examples
{exp:gmaps_data:query country_code="ru"}
{if no_results}
No result
{/if}
entry_id: {entry_id}<br>
lat: {lat}<br>
lng: {lng}<br>
city: {city}<br>
street_name: {street_name}<br>
street_number: {street_number}<br>
postal_code: {postal_code}<br>
country: {country}<br>
country_code: {country_code}<br>
{/exp:gmaps_data:query}
{exp:gmaps_data:radius location="new york" radius="50"}
{if no_results}
No result
{/if}
entry_id: {entry_id}<br>
distance: {radius}<br>
lat: {lat}<br>
lng: {lng}<br>
city: {city}<br>
street_name: {street_name}<br>
street_number: {street_number}<br>
postal_code: {postal_code}<br>
country: {country}<br>
country_code: {country_code}<br><br><br>
{/exp:gmaps_data:radius}
{exp:gmaps_data:radius location="new york" radius="55000000" limit="2" }
{if no_results}
No result
{/if}
entry_id: {entry_id}<br>
distance: {radius}<br>
lat: {lat}<br>
lng: {lng}<br>
city: {city}<br>
street_name: {street_name}<br>
street_number: {street_number}<br>
postal_code: {postal_code}<br>
country: {country}<br>
country_code: {country_code}<br><br><br>
{paginate}
{pagination_links}
<ul>
{first_page}
<li><a href="{pagination_url}" class="page-first">First Page</a></li>
{/first_page}
{previous_page}
<li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
{/previous_page}
{page}
<li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="page-next">Next Page</a></li>
{/next_page}
{last_page}
<li><a href="{pagination_url}" class="page-last">Last Page</a></li>
{/last_page}
</ul>
{/pagination_links}
{/paginate}
{/exp:gmaps_data:radius}
{!-- init gmaps http://docs.reinos.nl/gmaps/#init-tag --}
{exp:gmaps:init}
<h1>Search</h1>
{exp:gmaps_data:search_form
radius="500"
metric="km"
channel="gmaps_data"
location_field="location_field"
radius_field_max="radius_field_max"
search_type_field="search_type_field"
search_category_field="search_category_field"
result_url="gmaps-data/index"
}
<label>Location to search with (this location will be geocoded</label><br>
<input type="text" name="location_field" value="{location}"/>
<div id="radiusSearch">
<br><br>
<label>Radius (only uses when the search_type is set to 'radius')</label><br>
<select name="radius_field_max">
<option {if radius == 20}selected{/if} value="20">20</option>
<option {if radius == 50}selected{/if} value="50">50</option>
<option {if radius == 100}selected{/if} value="100">100</option>
<option {if radius == 5000}selected{/if} value="5000">5000</option>
</select>
</div>
<br><br>
<label>Search type</label><br>
<select name="search_type_field" onchange="hideRadiusSearch(this)">
<option {if search_type == 'radius'}selected{/if} value="radius">Radius</option>
<option {if search_type == 'locality'}selected{/if} value="locality">Within a City</option>
<option {if search_type == 'admin_level'}selected{/if} value="admin_level">Within a state or province</option>
<option {if search_type == 'sub_locality'}selected{/if} value="sub_locality">Within a city_district</option>
</select>
<script>
function hideRadiusSearch(elem){
if(elem.value !== 'radius')
document.getElementById('radiusSearch').style.display = "none";
}
</script>
<br><br>
<label>Search Category</label><br>
<select name="search_category_field">
{exp:channel:categories category_group="3"}
<option {if category_id == search_category:id}selected{/if} value="{category_id}">{category_name}</option>
{/exp:channel:categories}
</select>
<br><br>
<input type="submit"/>
{/exp:gmaps_data:search_form}
<h1>Search Result</h1>
{exp:gmaps_data:search_result limit="1"}
{if no_results}
No result
{/if}
entry_id: {entry_id}<br>
radius: {radius}<br>
lat: {lat}<br>
lng: {lng}<br>
city: {city}<br>
Admin level: {admin_level_1:name}<br>
street_name: {street_name}<br>
street_number: {street_number}<br>
postal_code: {postal_code}<br>
country: {country}<br>
country_code: {country_code}<br><br><br>
{!-- add a marker--}
{exp:channel:entries dynamic="no" entry_id="{entry_id}"}
{gmaps:add_marker map_id="1" latlng="{lat},{lng}" fit_map="yes" label="{count}" open_by_default="yes" infowindow="jaja"}
{/exp:channel:entries}
{paginate}
{pagination_links}
<ul>
{first_page}
<li><a href="{pagination_url}" class="page-first">First Page</a></li>
{/first_page}
{previous_page}
<li><a href="{pagination_url}" class="page-previous">Previous Page</a></li>
{/previous_page}
{page}
<li><a href="{pagination_url}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
{/page}
{next_page}
<li><a href="{pagination_url}" class="page-next">Next Page</a></li>
{/next_page}
{last_page}
<li><a href="{pagination_url}" class="page-last">Last Page</a></li>
{/last_page}
</ul>
{/pagination_links}
{/paginate}
{/exp:gmaps_data:search_result}
{!-- set a default map with no markers --}
{exp:gmaps:map center:address="holland" max_zoom="15"}
{exp:gmaps:init}
{!-- set a default map with no markers --}
{exp:gmaps:geocoding address:center="holland" max_zoom="15"}
<h1>Search</h1>
{exp:gmaps_data:search_form
radius="500"
metric="km"
channel="gmaps_data"
location_field="location_field"
radius_field_max="radius_field_max"
result_url="test/gmaps-data"
}
<input type="text" name="location_field"/>
<select name="radius_field_max">
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
<option value="5000">5000</option>
</select>
<input type="submit"/>
{/exp:gmaps_data:search_form}
<h1>Search Result</h1>
{exp:gmaps_data:search_result}
{if no_results}
No result
{/if}
entry_id: {entry_id}<br>
radius: {radius}<br>
lat: {lat}<br>
lng: {lng}<br>
city: {city}<br>
street_name: {street_name}<br>
street_number: {street_number}<br>
postal_code: {postal_code}<br>
country: {country}<br>
country_code: {country_code}<br><br><br>
{!-- add a marker--}
{exp:gmaps:add_marker map:id="1" latlng="{lat},{lng}" fit_map="yes"}
{/exp:gmaps_data:search_result}
{exp:channel:form channel="gmaps_data_channel" return="gmaps_data/channel-form" }
Titel: <input name="title" type="text"><br>
Url Title: <input name="url_title" type="text"><br>
{field:your_gmaps_data_field_name}
<input type="submit" value="Submit">
{/exp:channel:form}