Top Banner
PUT A MAP ON IT! Enhanced geolocation and mapping with Geo Mashup http://jeremyclarke.org • @jeremyclarke Download these slides: http://slideshare.net/jeremyclarke Creative Commons Share Alike http://creativecommons.org/licenses/by-sa/3.0/
30

Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

Aug 14, 2015

Download

Technology

Jeremy Clarke
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

PUT A MAP ON IT!Enhanced geolocation and mapping with Geo Mashup

http://jeremyclarke.org • @jeremyclarke

Download these slides:http://slideshare.net/jeremyclarke

Creative Commons Share Alikehttp://creativecommons.org/licenses/by-sa/3.0/

Page 2: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

WHO IS JEREMY CLARKE?

• Communications Studies at Concordia University.

• HTML+CSS since 2003

• Montreal WordPress Organizer

• Code & Design for Global Voices

Page 3: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

OUTLINE

• Geolocation concepts and tagging objects

• Geolocation in “core” WordPress

• Geo Mashup and different map types

• Configuring Geo Mashup

• Design considerations for map display

Page 4: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

WHAT IS GEOLOCATION?

• Choosing coordinates for objects

• Displaying location as metadata

• Displaying maps as navigation

• Searching for content by location

Page 5: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

GEOLOCATION IN WP?• Not really.

• Mobile app & wordpress.com allow geotagging

• Barely used in default themes (no maps)

• Standardized metadata for coordinates

https://en.support.wordpress.com/geotagging/

Page 6: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

GEOLOCATION IN WP?

https://en.support.wordpress.com/geotagging/

Page 7: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

WHY GEOLOCATE?

• Ambient awareness of locale (metadata)

• Colorful, serendipitous discovery (navigation)

• Hyperlocal content (search)

• Just in case (for later)

Page 8: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

MAP EVERYTHING?• No.

• Big, distracting, slow and heavy

• Rarely the most effective navigation

• Consider your unique content

• Use only when needed or harmless

• As always: Put users first

Page 9: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

https://wordpress.org/plugins/geo-mashup/

Page 10: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

WHY GEO MASHUP?• You need a plugin and this one works

• Powerful, customizable and integrated across WP

• Co-operates with standard WP geodata

• Has everything: Geotagging, mapping, radius search.

• Free and community-driven.

https://wordpress.org/plugins/geo-mashup/

Page 11: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

WHY NOT GEO MASHUP?• Overkill for many use-cases

• Complex to set up and test

• Requires custom styling (IMHO)

• Awkward code, subtle bugs

• Investigate other plugins if your needs are simple

https://wordpress.org/plugins/tags/geo

Page 12: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

EXAMPLE: RISING VOICES MICROGRANTS

• Navigate grant proposals via map

• Display proposal location on post view

http://rising.globalvoicesonline.org/amazonia-es/

Page 13: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

EXAMPLE: GLOBAL VOICES COMMUNITY BLOG

• Map of blog posts on homepage

• Optional location display (shortcode) in posts

http://community.globalvoicesonline.org/

Page 14: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

GEOTAGGING THINGS

Post editor geolocation User geolocation

Hard part: Choosing a single location

Page 15: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

MAP_CONTENT=GLOBAL

• Show all posts on the site

• Click for post preview

• Customize zoom level, style, post limits etc.

• Full power of WP_Query available

Page 16: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

MAP_CONTENT=SINGLE

• Show current post on a map

• Not very interactive

• Optional: Link back to global map

• Insert in content with shortcode

• Display in theme with PHP

Page 17: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

MORE MAP TYPES• Contextual: Show all posts in main WP_Query

• Radius: Show posts within $x km of a location

• Place: Search for country, city, town, postal code

• Custom: Pass in object_ids, WP_Query or taxonomy

• Users: Show your authors/community on a map

• OMG: More options than you want or need

Page 18: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

SHORTCODES & PHP

• Almost all features available as [shortcodes]AND as static PHP methods (functions).

• Shortcodes allow easy display inside post content.

• PHP gives precise control anywhere in your theme.

[geo_mashup_map] -> GeoMashup::map()

[geo_mashup_full_post] -> GeoMashup::full_post()

[geo_mashup_location_info] -> GeoMashup::location_info()

Page 19: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

SHORTCODES & PHP

[geo_mashup_map height="200" width="400" zoom="2" add_overview_control="false" add_map_type_control="false"]

<?php echo GeoMashup::map( ‘height=200&width=400&zoom=2&add_overview_control=false&add_map_type_control=false' );?>

echo GeoMashup::map( array( 'height' => 200, 'width' => 400, 'zoom' => 2, 'add_overview_control' => 'false', 'add_map_type_control' => 'false', );

Complex map: shortcode

Complex map: PHP+wp_parse_args()

Complex map: PHP+array

Page 20: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

OVERALL CONFIGURATION

Page 21: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

MAP-TYPE CONFIGURATION

Page 22: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

INDIVIDUAL MAP OPTIONS

Page 23: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

FIXING RESPONSIVENESS• Horribly unresponsive by default (fixed width+height)

• Use Width: 100% as baseline

• Use Height in px and find a balance

• Height is hardcoded for each map, can’t be responsive :(

Page 24: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

SPECIAL MOBILE CONFIG• Fixed height for desktop will never work for mobile

• Use MobileESP* and custom plugin code to identify small devices (smartphones)

• Filter height to fit in smartphone screen

• Filter zoom to to match new smaller size

• Consider hiding maps entirely for mobile devices :(

* https://github.com/ahand/mobileesp

Page 25: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

RESPONSIVE FUTURE?• Google Maps can be responsive* but not with Geo Mashup

• CSS hack to maintain aspect ratio (shape) across widths

• Hopefully: Future versions offer aspect ratio argument

* http://www.labnol.org/internet/embed-responsive-google-maps/28333/

Page 26: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

STYLING LOCATION POPUPS• Awful by default.

• Copy template file into your theme and edit to match:

geo-mashup-info-window.php

• Style CSS with .locationinfo

• Media queries target map iframe, not full window:@media only screen and (max-width:300px) {

.locationinfo {width: 160px;}}

Page 27: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

GEOLOCATING ATTACHMENTS• Not supported by Geo Mashup, but possible

• Combine with Media Library Assistant* plugin:

• Enables postmeta & taxonomy for attachments

• Imports metadata from images

• Can import GPS coordinates to standard WP storage*

https://wordpress.org/support/topic/geo-tag-custom-field

https://wordpress.org/plugins/media-library-assistant/

Page 28: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

GEOLOCATING ATTACHMENTS

http://middlememory.com/

Page 29: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

GEO MASHUP RESOURCES

• Features overview

• Tag reference (shortcodes and template tags)

• PHP API (helper functions and classes)https://github.com/cyberhobo/wordpress-geo-mashup/wiki/PHP-API

https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Tag-Reference

https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Feature-Usage

• GitHub repository (development and issue tracker)https://github.com/cyberhobo/wordpress-geo-mashup/

Page 30: Put A Map On It! Enhanced geolocation in WordPress with Geo Mashup

PUT A MAP ON IT!Enhanced geolocation and mapping with Geo Mashup

http://jeremyclarke.org • @jeremyclarke

Download these slides:http://slideshare.net/jeremyclarke

Creative Commons Share Alikehttp://creativecommons.org/licenses/by-sa/3.0/