mercredi 29 juin 2016

Google Maps api - label for markers

I want to include a cusom Map on my site, for the main part everything works, except for one thing.

The red marker needs a label, though I could add a icon and use that as marker, but I'd like to add the label without an extra image.

Also I don't want to use extra plugins.

If this doesn't work: Is it possible to add the mapoptions to the standard embed map? The only downside there is that it zooms upon scrolling.


Look of the current map:

Custom Map


Label the Marker should have:

Google Map

Brandenburger Gate - Google Maps


HTML:

<div id="googleMap"></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

Javascript (jQuery):

$(function() {

    function showMap() {

        var mapZoom = 14;
        var LatLng = new google.maps.LatLng(52.516275, 13.377704);

        var mapOptions = {
            zoom: mapZoom,
            center: LatLng,
            streetViewControl: false,
            scrollwheel: false,
            navigationControl: false,
            mapTypeControl: false,
            scaleControl: false,
            keyboardShortcuts: false

        };

        var map = new google.maps.Map(document.getElementById('googleMap'),mapOptions);

        var marker = new google.maps.Marker({
            position: LatLng,
            map: map,
            draggable: false
        });
    }
    google.maps.event.addDomListener(window, 'load', showMap);

});

Aucun commentaire:

Enregistrer un commentaire