WordPress.org

Ready to get started?Download WordPress

Forums

WP Flexible Map
[resolved] Using kml and center tag together (5 posts)

  1. japhys
    Member
    Posted 11 months ago #

    I am loading a kml file, works great!! However I would like to have Europe (or even country / City) centered. If I use center tag, it works but then my kml file is not being loaded. Is there anyway to use them together or maybe another way to achieve this?

    Thanks in advance!

    Japhys

    http://wordpress.org/plugins/wp-flexible-map/

  2. webaware
    Member
    Plugin Author

    Posted 11 months ago #

    G'day Japhys,

    You'll need to add a little JavaScript to your page for this. You need to set the centre on the map (and perhaps also zoom it) once the page has loaded. The KML layer might still be loading tiles then too, so you'll need to set it again after the tiles have loaded. Here's a snippet that you can add to your page. Give the map an id so that the script can find it, e.g. id=my_kml_map

    <script>
    jQuery(window).on("load", function() {
        if (window.flxmap_my_kml_map) {
            var flxmap = window.flxmap_my_kml_map,
                map = flxmap.getMap(),
                centre = new google.maps.LatLng(-32.918657,151.797894);
    
            flxmap.setCenter(centre);
            map.setZoom(13);
    
            google.maps.event.addListenerOnce(map, "tilesloaded", function() {
                map.setCenter(centre);
                map.setZoom(13);
            });
        }
    });
    </script>

    cheers,
    Ross

  3. japhys
    Member
    Posted 11 months ago #

    Thanks a lot for your quick reply!!

  4. webaware
    Member
    Plugin Author

    Posted 11 months ago #

    No worries, is it working for you now?

    cheers,
    Ross

  5. japhys
    Member
    Posted 11 months ago #

    Yup got it working :)

Reply

You must log in to post.

About this Plugin

About this Topic