caption marker google maps

Asked

Viewed 239 times

1

I use the cornford google googlmapper package of the Laravel where all intelligence is in the controller and then moves to the view via java script rendered, I need to insert caption in the map marker so that it is the same as the example below:inserir a descrição da imagem aqui

1 answer

0

The manipulation of texts in mark is very complex and limited. I found no way to do this, except by using the markerwithlabel library.

Using the same simply create the markwithlabel:

js:

marker = new MarkerWithLabel({
                        position: new google.maps.LatLng(point.Latitude, point.Longitude),
                        icon: icon.jpg,
                        labelContent: "Ponto de chegada",
                        labelAnchor: new google.maps.Point(62, 42),
                        labelClass: "my-custom-class-for-label",
                        map: map
                    });

And create the class that responds to his training:

.my-custom-class-for-label {
            text-align: left;
            font-weight: bold;
            font-size: 20px;
            color: #fff;
        }

Remembering that it is important that you include the same scripts in your project, you can copy this js (https://github.com/LuizSD/mapsWithUrlParam/blob/master/js/markerwithlabel.js)

Example of use: https://github.com/LuizSD/mapsWithUrlParam

Text explaining use: https://medium.com/@barvysta/google-Marker-api-Lets-play-level-1-Dynamic-label-on-Marker-f9b94f2e3585

  • Thanks already more didn’t work, I don’t know why these parts aren’t working: labelContent: "Finish point", labelAnchor: new google.maps.Point(62, 42), labelClass: "my-custom-class-for-label",

  • Opa, you even included the https://github.com/LuizSD/mapsWithUrlParam/blob/master/js/markerwithlabel.js library you need to add it to your project. Only then it will be possible to instantiate an object of type Markerwithlabel.

  • In this object you can use the attributes labelClass and labelContent. Which are the content of the label and the class that it respects

  • I imported the Library when use: new google.maps.Marker the marker appears as in the example more when use: Markerwithlabel the image some does not appear

Browser other questions tagged

You are not signed in. Login or sign up in order to post.