question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom marker with label

See original GitHub issue

I’m submitting a … (check one with “x”) [ X ] question

plugin version: [X] 2.0.0-beta3

cordova information: (run $> cordova plugin list)

com.googlemaps.ios 2.3.0 "Google Maps SDK for iOS"
cordova-plugin-console 1.0.7 "Console"
cordova-plugin-device 1.1.6 "Device"
cordova-plugin-googlemaps 2.0.0-beta3-20170817-0747 "cordova-plugin-googlemaps"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Currently, I am using the Google Maps JS SDK within an Ionic 3 app.

I used markerWithLabel library https://github.com/googlemaps/v3-utility-library so I can have a custom label like in the image below.

http://imgur.com/a/FZ1Qi

My question is that how it is possible to make exactly the same with cordova-plugin-googlemaps as I think, it’s not possible to make markerWithLabel library work with cordova-plugin-googlemaps ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
alicarlocommented, Aug 24, 2018

Sorry my English is bad It is my first post

If someone serves you, I could add a custom label on the map, add a second marker, create a canvas and convert it to base64 and assign it to the marker and it worked code example

addMarker(){
this.example.forEach((data: any) => {
      var canvas, context; 

      canvas = document.createElement("canvas");
      canvas.width = 50;
      canvas.height = 30;
      var  x=1, y=1, width=45, height=15, radius=0,  stroke= true;
      context = canvas.getContext("2d");
      if (typeof stroke == "undefined" ) {
        stroke = true;
      }
      if (typeof radius == "undefined") {
        radius = 5;
      }
      context.beginPath();
      context.moveTo(x + radius, y);
      context.lineTo(x + width - radius, y);
      context.quadraticCurveTo(x + width, y, x + width, y + radius);
      context.lineTo(x + width, y + height - radius);
      context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
      context.lineTo(x + radius, y + height);
      context.quadraticCurveTo(x, y + height, x, y + height - radius);
      context.lineTo(x, y + radius);
      context.quadraticCurveTo(x, y, x + radius, y);
      context.fillStyle = "white";
      context.fill();
      context.closePath();
      if (stroke) {
        context.stroke();
      }
    context.lineWidth = 1;
    context.strokeStyle = "#ffffff";
    context.font="12px Arial";
    context.textAlign="center"; 
    context.fillStyle = "black";
    context.fillText(data.name,22,12);

   var pngUrl = canvas.toDataURL("image/jpg");

   let marker: Marker = this.map.addMarkerSync({
        icon: data.icon,
        animation: 'DROP',
        position: {lat:data.lat, lng:data.lon},
      });
      marker.setZIndex(2);
      let marker2: Marker = this.map.addMarkerSync({
      icon: pngUrl,
      position: {lat:data.lat, lng:data.lon}
      });
      marker2.setZIndex(1);
      });

labelsnative

that the code is helpful

0reactions
wf9a5m75commented, Aug 19, 2017

Create a canvas, draw a image, then draw your text on the canvas, then export base64 encoded strings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Marker Labels | Maps JavaScript API - Google Developers
This example creates a map where each click by the user creates a marker that's ... Add the marker at the clicked location,...
Read more >
Customize Google Map API V3 Marker label - Stack Overflow
I want to customize the label. I try to find the answers in google documentation they have only few properties to change (https://developers.google.com/maps/ ......
Read more >
Google map with labelled markers - Cheppers
We can define a custom label to each marker by the label property of the Marker object. If the Marker has label attributes,...
Read more >
Custom styles for Marker Label · Issue #1699 - GitHub
A user should have the ability to style a marker label using a css class or through the label option when creating a...
Read more >
Custom Pipe Markers & Pipe Labels - Emedco
Emedco's custom pipe markers come in both snap-around and self-adhesive materials to fit any pipe. Visit us online and design your own pipe...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found