AppGeolocation Shortcodes

We belong to a global community of people spread out across the world, yet connected to each other with mobile devices. Many are constantly on the move, bringing their smartphones and tablets along with them. With the geolocation technology present within these mobile devices, there exists the capability to request a user's latitude and longitude information, and utilize that information in multiple ways. With AppGeolocation, we have made it easy to tap into the user's mobile device geolocation information and create or update posts with it.

[app-geolocation] shortcode

Creating unique checkins.

If you are building app functionality that relies on a user creating new checkins, AppGeolocation is perfectly capable of accommodating this. You can set the shortcode to create new posts within any post type you want, with the user as the author. On top of that, you can allow the user to set a title and post content with it. You could visualize this similar to how Foursquare acts.

You can get started with recording and posting the necessary information with the following settings

[app-geolocation action="new" post_type="userlocation" post_title="true" post_content="true"]

Note: Substitute your own post_type slug where "userlocation" is shown above. 

If you are interested in having moderation for each posting, there is the post_status shortcode attribute available. It defaults to publish but would accept any post type status that is natively available to WordPress. Preferably draft for this moderation example.

Map previews of the current location are available if you set the map_preview attribute. This will query Google Maps™ for a static image of the provided coordinates.

Updating user's location.

Imagine for a moment that you have a company that has goods that need to be kept track of, but is not always used by the same employee every day. A good example of this could be a fleet of vehicles. If you are keeping information uptodate with a custom post type, AppGeolocation has all the capability to help update that vehicle's location. You can put an instance of the [app-geolocation] shortcode on the single post for each vehicle, and let your employees update from there. Due to the default settings for the shortcode, the only attribute you'd really need to consider is the force_login boolean attribute. This would make it so employees would need to be logged in, in order to post the geolocation information.

[app-geolocation force_login="true"]

These are just some examples of what could be done with the AppGeolocation extension. Hopefully you can think of more examples as well. For more information on all of the shortcode's attributes, visit the AppGeolocation Extension page.

[app-geolocation]

Attribute type Details Available parameters
force_login boolean Whether or not the user must be logged in to use the geolocation features. false, true 
Default: false
action string Whether or not to post to the current post/page or create a new post. Use  this to post to the current post/page. this, new 
Default: this
post_type string Allows you to specify a post type to post the user's location to. Note: this parameter can only be use when action is "new" any post types that are registered. 
Default: post 
Note: use the post type slug.
post_title boolean Sets whether to display a "title" field for the form. If set to true, the form will display a "Title" field that you can use to name the created post. false, true 
Default: false
post_content boolean Sets whether to display a "post content" field for the form. If set to true, the form will display a "post content" field that you can use to add to the content area. false, true 
Default: false
post_status string Sets the post status for the new post. draft, publish 
Default: publish
map_preview boolean Whether or not to show a map preview for the posting. false, true Default: false

Examples:[app-geolocation force_login="true"] [app-geolocation action="new"] [app-geolocation action="new" post_type="user_location"] [app-geolocation post_title="true"] [app-geolocation post_content="true"] [app-geolocation post_status="draft"] [app-geolocation map_preview="true"]

[appp-map] shortcode

Display a Google map with your checkins as markers

Introduced in AppGeolocation 2.2.0. Once you have collected checkin data either as the checkin custom post type, as a user's meta or as any post type's meta, you can display those as markers on a map. There are several options that lets you customize the map with the following parameters:

[appp-map] 
[appp-map source="user" zoom="auto"] 
[appp-map source="checkin"]
[appp-map zoom="3" height="600" center_lat="37.4419" center_long="-122.1419"]

Parameters

Attribute type Details Available parameters
source string This will display the geolocations from the checkin post type, post meta and user meta. 
all (default) 
user This will display the geolocations from the user meta.
checkin This will display the geolocations from the checkin post type.
all, user, checkin 
Default: all
zoom string, integer 0-20 Any number between 0 - 20.
auto Auto zoom and auto center around your markers.  This option cannot be used with center_lat or center_long.
all, user, checkin 
Default: all
selector string map-container The HTML id parameter like <div id="map-container"></div> Default: map-container
height string, integer 600 or 600px The number of pixels you want the map to be. Default: 600
center_lat float 37.4419 The latitude where you want the map centered. If left empty the map will use fitBound to center the map around all of your markers. Default: 37.4419 (the default can be changed with filter)
center_long float -122.1419 The longitude where you want the map centered. Default: 122.1419 (the default can be changed with filter)

Filter Hooks

[app-geotracking] shortcode

Saves user's latitude and longitude to their user meta.

You must enable this feature in the WP-Admin of your WordPress site in the AppPresser settings under the Geolocation tab. You can customize it with the following parameters:

[app-geotracking]
[app-geotracking prompt="5" use_click="false"]
[app-geotracking use_click="true"]Click here to begin[/app-geotracking]

Parameters

Attribute type Details Available parameters
prompt string The number of seconds to pause before geotracking begins. This allow users to read any content on the page before they get a prompt from the device to allow access to their location. Default: 5
use_click string Requires the user to click a button before geotracking begins. true or false
Default: false

Geotracking Advance use with JavaScript

To start the geotracking you can use the following JavaScript

Start
parent.postMessage('{"geouserpref":{"interval":60000,"wordpress_url":"https://your-wp-site.com/"}}', '*');
Stop
parent.postMessage('{"geouserpref":{"interval":0,"wordpress_url":"https://your-wp-site.com/"}}', '*');

The geotracking will also stop once the app is closed.