WordPress.org

Support

Support » Plugins and Hacks » WP Geo » [Resolved] WP-Geo KML Overlay

[Resolved] WP-Geo KML Overlay

  • We are using WP-Geo on http://accesslocal.tv and would like to overlay a outline of a particular neighborhood zone. We have created a KML file and have tried using the overlay example from the documentation but we are not sure that the code is correct or being inserted into the right PHP files. We have tried adding the following to maps.php, wp-geo.php, and functions.php:

    function my_wpgeo_map_js_preoverlays( $content, $gmap ) {
    $js = ‘ geoXml = new GGeoXml(“http://accesslocal.tv/wp-content/uploads/wp-geo/kml/bhc_zone.kml”; ‘ . $gmap . ‘.addOverlay(geoXml); ‘;
    return $content . $js; }

    add_filter( ‘wpgeo_map_js_preoverlays’, ‘my_wpgeo_map_js_preoverlays’ );

    Is this even close? Also, what PHP file should we modify? Also, do we need to add any code to the site header?

    Thanks for your help, your plugins add a lot to our community driven site!

    http://wordpress.org/extend/plugins/wp-geo/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Ben Huson

    @husobj

    You can put the code in your theme’s functions.php file.

    Couple of mistakes in your code:

    1. Need a closing bracket after …bhc_zone.kml”
    2. Using add_filter you need to specify priority and number of parameters

    See updated code below

    function my_wpgeo_map_js_preoverlays( $content, $gmap ) {
            $js = ' geoXml = new GGeoXml("http://accesslocal.tv/wp-content/uploads/wp-geo/kml/bhc_zone.kml");
            ' . $gmap . '.addOverlay(geoXml);
            ';
            return $content . $js;
    }
    add_filter( 'wpgeo_map_js_preoverlays', 'my_wpgeo_map_js_preoverlays', 10, 2 );

    Thanks for the quick update! We tried this and it worked great with the maps at the bottom of the posts, but did not add the overlay to the widget maps or the big map.

    We have posted a request with the author of the WP-Geo Big Map plugin; do you have any ideas of how we can make this work with the widget map and the big map?

    Thanks again!

    Plugin Author Ben Huson

    @husobj

    Not sure about the Big Map plugin.

    Widgets don;t current use the wpgeo_map_js_preoverlays filter but you could trying applying the it by editing the WP Geo plugin widgets/wpgeo-widget.php file round line 255 to something like this:

    map.setCenter(center, zoom);
         ' . apply_filters( 'wpgeo_map_js_preoverlays', '', 'map' ) . '
    }
    Plugin Author Ben Huson

    @husobj

    The wpgeo_map_js_preoverlays filter should be in widgets in WP Geo 3.2.7.2+

    It is possible to do something similar with api3?

    Thanks for your help

    Plugin Author Ben Huson

    @husobj

    API3 still uses the wpgeo_map_js_preoverlays filter.

    Refer to the Google Maps API3 KML examples for help implementing a KML layer.

    Thanks for this, but I’m confused. What code am I supposed to be putting into my Theme functions in order for overlays to work on API3?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] WP-Geo KML Overlay’ is closed to new replies.
Skip to toolbar