Forums

WP Geo
[resolved] WP-Geo KML Overlay (5 posts)

  1. foxyea
    Member
    Posted 6 months ago #

    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/

  2. Ben Huson
    Member
    Plugin Author

    Posted 6 months ago #

    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 );
  3. foxyea
    Member
    Posted 6 months ago #

    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!

  4. Ben Huson
    Member
    Plugin Author

    Posted 4 months ago #

    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' ) . '
    }
  5. Ben Huson
    Member
    Plugin Author

    Posted 3 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic