
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Angular 2 simple wrap of Google Map API
There are some complex wrap that allows you to place markers in Google Map in a way similar to place elements in a parent element. However, those are too heavy as a wrap for Google Map API.
To make the API as light as possible, here I provide a simple solution that allows you to load Google Map API.
In your @NgModule
@NgModule({
imports: [ ErrisyMapModule.forRoot({ key: 'Your Google Map API Key' }), ...YourModules],
declarations: [ ...YourComponents],
entryComponents: [],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
In your component html, where you want to use Google Map. The selector is [google-map].
MapInit is the most important part, which is the callback when Google Map is loaded. You can then do additional setups such as load customized Google Map Markers.
<div google-map [Lng]="location.x" [Lat]="location.y" [Zoom]="12" (MapInit)="onMapReady($event);" class="app-map">
</div>
Since Google Map API is loaded asynchronously, you can not extend their classes until you have loaded the API.
To extends the API classes, you must import the API after Google Map is loaded.
With SystemJS in Angular 2, there is a simple solution:
//Define your own marker by extending Google Map Marker in file 'customized.marker.ts'
export class MyCustomizedMarker extends google.maps.Marker{
}
Then you can load it via SystemJS.import in the MapInit callback.
import * as CustomizedMarkers from 'customized.marker'; // this will just import the definition, it will disappear in the compiled the .js file.
@Component({
selector: 'app',
template: `
<div google-map [Lng]="location.x" [Lat]="location.y" [Zoom]="12" (MapInit)="onMapReady($event);" class="app-map">
</div>
`
})
export class MyApp{
this.CustomizedMarkersModule: typeof CustomizedMarkers;
onMapReady($event: google.maps.Map){
this.CustomizedMarkersModule = await SystemJS.import('...foldername/markers.js'); //load the customized marker module
let myMarker = new CustomizedMarkersModule.MyCustomizedMarker(); //create your customized marker
}
}
FAQs
Angular 2 simple wrap of Google Map API
We found that errisy-map demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.