Skip to content
This repository was archived by the owner on Dec 15, 2018. It is now read-only.
This repository was archived by the owner on Dec 15, 2018. It is now read-only.

Support the asynchronous maps API. #1

Open
@JimBobSquarePants

Description

@JimBobSquarePants

At present the script requires the core map code to be already present in the page which prevents asynchronous loading of maps whilst using the MapLabel function.

https://github.com/googlemaps/js-map-label/blob/gh-pages/src/maplabel.js#L44

It would be better, in my opinion, if the prototypical properties were copied from OverlayView on first
instance of the constructor getting initialised. That would allow someone to asynchronously load the map script and instantiate inheritance when calling new MapLabel for the first time.

function MapLabel(opt_options) {

    if (!MapLabel.prototype.setValues) {
        // Copy the properties over.
        for (var prop in google.maps.OverlayView.prototype) {
            MapLabel.prototype[prop] = google.maps.OverlayView.prototype[prop];
        }
    }

    this.set('fontFamily', 'sans-serif');
    this.set('fontSize', 12);
    this.set('fontColor', '#000000');
    this.set('strokeWeight', 4);
    this.set('strokeColor', '#ffffff');
    this.set('align', 'center');

    this.set('zIndex', 1e3);

    this.setValues(opt_options);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions