WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. foxyea
    Member
    Posted 1 year 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 1 year 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 1 year 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 1 year 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 1 year ago #

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

  6. ppalli
    Member
    Posted 11 months ago #

    It is possible to do something similar with api3?

    Thanks for your help

  7. Ben Huson
    Member
    Plugin Author

    Posted 11 months ago #

    API3 still uses the wpgeo_map_js_preoverlays filter.

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

  8. sensiblestu
    Member
    Posted 9 months ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic