Support » Plugin: Flexible Map » Using kml and center tag together

  • Resolved japhys

    (@japhys)


    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/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author webaware

    (@webaware)

    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

    Thanks a lot for your quick reply!!

    Plugin Author webaware

    (@webaware)

    No worries, is it working for you now?

    cheers,
    Ross

    Yup got it working 🙂

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using kml and center tag together’ is closed to new replies.