Code Monkey home page Code Monkey logo

angular-maps's Introduction

npm version angular-maps Code Climate All Contributors

- #IMPORTANT
- On or about 10/6/2019, this repository will be migrated into the Avanade channel. While existing clones,
- forks and branches will automatically redirect, we recommend that after the migration you repoint
- your urls to the Avanade channel. 

Overview

Angular Maps (X-Map) is a set of components and services to provide map functionality in angular 2+ apps. X-Maps architecture is provider independent and can be used with Bing, Google, ESRI or any other service enabled mapping provider. X-Map contains default implementations for Bing Maps and Google Maps, including layers, markers, infoboxes, clusters, polygons and polylines for both platforms.

- we have now added support for angular 6 and changed the examples to stackblitz...

Samples

You can find various basic and advanced samples in the Wiki Sample Page

Latest Updates

See the Wiki Change Log for key changes and addition in various releases.

Install

Install via npm:

    npm install --save angular-maps

Use

To use angular-maps with the default Bing Map implementation, follow these three steps:

  1. Import Module
  2. Configure Services
  3. Add a map, markers, infoboxes and actions to a component

1. Import Module

Add the Bing Type Declarations to your main app module (or a particular feature module, if you don't want it globally). This is currently necessary even if you do not want to use the Bing Maps providers as the types are in the signatures but not part of the distribution (the bingmaps Typescript types npm package is part of the dependencies and should have been installed when you installed angular maps). We are looking for ways around that... In the meanwhile, insert the following on the top of your app module file (depending on your project structure, you might have to manipulate the path):

    /// <reference path="node_modules/bingmaps/types/MicrosoftMaps/Microsoft.Maps.All.d.ts" />

Import MapModule, MapAPILoader, BingMapAPILoaderConfig, BingMapAPILoader, WindowRef, DocumentRef, MapServiceFactory and BingMapServiceFactory (yeah, I know...) in your main app module (or a particular feature module, if you don't want it globally).

    import { MapModule, MapAPILoader, BingMapAPILoaderConfig, BingMapAPILoader, WindowRef, DocumentRef, MapServiceFactory, BingMapServiceFactory } from "angular-maps";

Import the MapModule. Note that the module is designed for lazy loading, so call with .forRoot()...

    @NgModule({
        bootstrap: [ AppComponent ],
        declarations: [
            ...
        ],
        imports: [
            ...
            MapModule.forRoot()
            ...
        ],
        providers: [
            ...
        ]
    })

2. Configure Services

Theoretically, this is optional. However, generally you will need to supply some configuration to your map service, such as the service key or some such. You do that by injection specifc service configurations in the root module. The two service you will need to configure is the loader (which is actually responsible to load the resources from the map provider such as scripts etc) and the Service Factory, which provides bootstrapping for the concrete implementation (Bing, Google, etc) you want to be using. Currently only a bing provider exists.

    @NgModule({
        bootstrap: [ AppComponent ],
        declarations: [
            ...
        ],
        imports: [
            ...
            MapModule.forRoot()
            ...
        ],
        providers: [
            ...
            {
                provide: MapAPILoader, deps: [], useFactory: MapServiceProviderFactory
            }
            ...
        ]
    })

    export function MapServiceProviderFactory(){
        let bc: BingMapAPILoaderConfig = new BingMapAPILoaderConfig();
        bc.apiKey ="..."; // your bing map key
        bc.branch = "experimental"; 
            // to use the experimental bing brach. There are some bug fixes for
            // clustering in that branch you will need if you want to use 
            // clustering.
        return new BingMapAPILoader(bc, new WindowRef(), new DocumentRef());
    }

Note: The provider factory was moved into an exported method to accomodate Angular 4 requirements to no have lambda functions in the provider loading.

3. Add a map, markers, infoboxes and actions to a component

To use maps, create a simple component (or implement the below in an existin component) as follows:

    import { Component } from '@angular/core';
    import { IBox, IMapOptions, MarkerTypeId } from "angular-maps";
    
    @Component({
        selector: 'some-component',
        template: `
            <div style="height: 500px">
                <x-map #xmap [Options]="_options">
                    <x-map-marker
                        [Latitude]="30" 
                        [Longitude]="90" 
                        [Title]="'My Marker'" 
                        [IconUrl]="'https://cdn0.iconfinder.com/data/icons/industrial-icons/164/2-128.png'" 
                        [IconInfo]="{
                            markerType: _markerTypeId.FontMarker,
                            fontName: 'FontAwesome',
                            fontSize: 48,
                            color: 'green',
                            markerOffsetRatio: { x: 0.5, y: 1 },
                            text: '\uF276'
                        }"> 
                        <info-box [DisableAutoPan]="true" [Title]="'My InfoBox'" [Description]="'Hi, this is the content of the <strong>info window</strong>. It is your responsibility to implement functionality such as close, etc...'">
                            <info-box-action [Label]="'Click Me'" (ActionClicked)="_click()"></info-box-action>
                        </info-box>   
                    </x-map-marker>
                </x-map>
            </div>
        `,
        styles: []
    })
    export class SomeComponent {
       private _markerTypeId = MarkerTypeId 
            // a little trick so we can use enums in the template...

       private _options: IMapOptions = {
            disableBirdseye: false,
            disableStreetside: false,
            navigationBarMode: 1
       };
            // for all available options for the various components, see IInfoWindowOptions, IInfoWindowAction, IMarkerOptions, IMapOptions, IMarkerIconInfo

       private _click(){
           console.log("hello world...");
       }
   }

Some notes:

  • You can data bind map-markers to arrays of information via *ngFor. Very handy!
  • You can use full rich text in the body of the info-box directive, this lets you fully control the appearance of the info-box. However, when you do that, info-box-actions won't work and you have to implement your own action mechanism.
  • In my experience, when you have a large number of markers and you need a customized experience, it is easiest to implement a shard infobox. I'll have an example in the Wiki soonish.

Happy Mapping!

If you want to help

As with all these, I am looking for help in evolving this module. The top things on the agenda:

  • Adding Polygon capabilities (abstract and concrete for Bing) is the highest priority.
  • Clustering support needs to be improved.
  • Currently the markers are directly placed on the map. Moving them into (optionaly multiple) layers would be good for larger app scenarios. (done for Bing, still in progress for Google)
  • Looking for someone to implement a Google Maps wrapper implementing thin proxy services against Angular Google Maps
  • Looking for someone to create a set of ESRI concrete implementations.
  • Performance improvements for very large data sets (more than 10000 markers, polylines and polygones, polylines and polygones with 100000 path points).
  • Add Circle Component and support
  • Add KML layer capability.
  • Add GeoJSON capability.
  • Add Server side rendering support with sample tile server implementation.

Implementing your own Provider

The angular-maps module allows for the implementation of various different providers. Even though currently only Bing is implemented, implementing your own provider against Google, Esri or others is straight forward as long as the underlying capabilities are there. In order to do that you need to:

  1. Create concrete implementations of the Marker and InfoBox abstracts (see BingMarker and BingInfoWindow for guidance)
  2. Create concrete implementations of the MapAPILoader, MapService, MarkerService and InfoBoxService abstracts (again, see the Bing implementation in this project for guidance)
  3. Create a concrete implementation of the MapServiceFactory to bootstrap the various services.
  4. Inject your service implementations in the provider (see configure services above).

Happy coding!

Advanced

Check out the Wiki for detailed documentation on components, models and providers.

angular-maps's People

Contributors

chrisbright10 avatar christophersenn avatar dahovey avatar luixaviles avatar metaceo avatar thor-schueler avatar zubairv85 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-maps's Issues

Minimum Cluster Size Broken

I specified <x-cluster-layer [GridSize]="50" [ClusteringEnabled]="true" [UseDynamicSizeMarkers]="true" [DynamicMarkerBaseSize]="18" [DynamicMarkerRanges]="ranges" [MinimumClusterSize]="4"> in my html but still I get clusters of 3 or 2. In my data sometimes I have several points with the exact same lat long and zooming into the lowest level and still only being able to see a cluster marker instead of the points won't work.

Rotated icons keep growing in size with every Angular repaint

Issue:
Rotated icons in the Angular view state keep growing in size.

Diagnosis:
When a rotated marker gets created it gets a bigger size assigned as a rotated image takes more space than a non-rotated image.
Without icon being cached through an id, the icon gets larger every repaint of the state. It looks like the boilerplate code recalculates the "new" rotated size every time assuming the current size is the size of the original picture, which in the current version is the rotated size.
E.g. Image starts with dimensions [40, 53]. After rotation the icon becomes [65, 65]. After a repaint the icon becomes [75,75] etc.
Current workaround is to assign a unique value to the id property on the icon object which enforces the boilerplate to reuse what is in the cache without recalculating the size.

Currently using the following "icon factory"; which requires a unique id for every call:

createIcon(id: string, rotation: number): IMarkerIconInfo {
        return {
            id: id,
            markerType: MarkerTypeId.RotatedImageMarker,
            rotation: rotation,
            markerOffsetRatio: { x: 0.5, y: 0.5 },
            url: '/assets/my-beautiful-image.png',
        };
    }

Clearing clusters

Hi @thor-schueler I am having issue while loading clearing the clusters and loading the new clusters according to new information coming from the data.

I have seen the google map api which has a functionality to clear the clusters. Can you please help me with this.

Thanks!!

Cannot find namespace Microsoft

error TS6053: File '/node_modules/bingmaps/types/MicrosoftMaps/Microsoft.Maps.All.d.ts' not found.`

Please update your installation instructions to also include a manual effort of executing 'npm install bingmaps' because angular-maps doesn't come with it out of the box.

Bing Maps - Editable polygon

I've forked this repository and was hoping to add support for editing polygons with Bing Maps, but I had some questions/issues:

  1. When I run npm install the following error occurs apparently from linting. After removing prepublish script from package.json the error no longer occurs.

ERROR: src/services/bing/bing-cluster.service.ts[248, 75]: Shadowed name: 's'` a

  1. When I run npm run build I receive errors:

Error at C:/temp/angular-maps/src/models/bing/bing-cluster-layer.ts:113:41: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
Error at C:/temp/angular-maps/src/models/bing/bing-cluster-layer.ts:130:41: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
Error at C:/temp/angular-maps/src/models/google/google-marker-clusterer.ts:87:41: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.
Error at C:/temp/angular-maps/src/models/google/google-marker-clusterer.ts:102:41: The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter.

  1. Should I create a new branch for my changes?
  2. Is there a date you hope to publish current changes in master branch?

Thanks for your help!

Generating circle paths

I am trying to generate paths for circles but don't understand how it should be done as the MapService is not exposed. Would I need to use the native methods, and then translate the result to ILatLong?

Microsoft.Maps.SpatialMath.getRegularPolygon

An example is given on the bing maps repo here, is there any similar example?

Another typo :)

MapService.GetRandonLocations
should be:
MapService.GetRandomLocations

doesn't it work in ng5 ?

I followed all instructions and have this error
Error: Unexpected value '[object Object]' imported by the module 'MyModule'. Please add a @NgModule annotation.

The error is somewhere in module - MapModule.forRoot()

Multi color pin points.

@thor-schueler
I want to have different colored PIN POINTs/MARKERS based on some condition, which i am getting from some data source. So lets say, I would need some of the pin points as GREEN color and some of the points as RED color, but since you are using only single object, i am not able to handle that scenario using your plugin. Is there any work around in this we can do? Can you please let me know if its possible?

Marker Offset

When using the FontMarker or the ScaledImageMarker, I can't appear to set the marker offset properly. For example the bottom middle of image is where I may want to represent the point on the map. I've tried using the markerOffsetRatio, but it doesn't seem to do affect anything. Should I be using a different property to offset the image?

Incompatible with NG5 Angular App??

Is angular-maps compatible with Ng5?
I have followed the exact instructions mentioned in your documentation, but my App throws this error: compiler.js:486 Uncaught Error: Unexpected value 'MapModule' imported by the module 'AppModule'. Please add a @NgModule annotation.

In my Angular App's package.json: "angular/core": "^5.2.9"
In package.json of angular-maps module: "angular/core": "^4.4.6"

Is there a good resource online that I can follow for creating a angular-maps component in Ng5? I am interested in getting bingmaps basic implementation working.
thanks.

customMapStyle

Hi. I need add custom style for map. I add options
_options: IMapOptions = {
disableBirdseye: false,
disableStreetside: false,
navigationBarMode: 1,
zoom: 6,
customMapStyle = {
"elements": {
"water": { "fillColor": "#a1e0ff" },
"waterPoint": { "iconColor": "#a1e0ff" },
"transportation": { "strokeColor": "#aa6de0" },
"road": { "fillColor": "#b892db" },
"railway": { "strokeColor": "#a495b2" },
"structure": { "fillColor": "#ffffff" },
"runway": { "fillColor": "#ff7fed" },
"area": { "fillColor": "#f39ebd" },
"political": { "borderStrokeColor": "#fe6850", "borderOutlineColor": "#55ffff" },
"point": { "iconColor": "#ffffff", "fillColor": "#FF6FA0", "strokeColor": "#DB4680" },
"transit": { "fillColor": "#AA6DE0" }
},
"version": "1.0"
};
};
but get error in console " 'customMapStyle' does not exist in type 'IMapOption' ".

Bing Maps - Changing Polygon Color properties

Found an issue with changing FillColor and/or StrokeColor after the polygon has been created. It only occurs with Bing. When consumer is using both opacity and color, then if you change the color the opacity value isn't used.

I believe inside map-polygon.ts in GeneratePolygonChangeSet, if present, the opacity value should be sent along with color changes.
map-polygon.ts

Here is plunker showing issue. Click button above map to trigger change.
https://plnkr.co/edit/xxTSUqc6uHgVYy12mZqP?p=preview

Change the cluster style

Hi there,

Can we change the cluster icon and add a svg instead of the default image:

screen shot 2018-08-09 at 20 36 38

So far I tried to play with the inputs IconInfo, ClusterIconInfo and Styles without success.

That would be truly awesome :)

Thanks!

Rendering Markers and Polylines in a separate window

In my application I use GoldenLayout to display several components on one screen with the ability to drag and drop windows, and pop them out into separate windows. My map is one of these components. Everything works perfectly when the map is docked, but as soon as I pop it out into a separate window the map will no longer update the UI at all. I have two lists that I loop through in an *ngFor of custom objects that have all the various pieces of information I need to create the marker and associated infobox (i.e. lat, long, iconUrl, and several variables I use in the description of the infobox). Going through the debugger I can see that when it's popped out the events are still triggering and the map component is receiving them and the two lists I use are holding the proper data, but it won't appear in the map. I've attached a screenshot of the error I got every time the map receives the event that tells it what to display.

map_error

I understand this is a complex issue, but I was wondering if you had any insight on what may be preventing the map from updating markers and polylines even though the data has changed. Any help you can offer is greatly appreciated!

Infobox load error

I think this is a bug with x-info-box. I haven't found a way to consistently repeat it, but when I load my infoboxes occasionally they all end up like this.

infobox_error

It's like all the infoboxes were rendered all in one location. Also, if you mouse hover over them they slowly close out, but since there's about 50-100 of them it takes awhile for them to all close.

[Question] How can I subscribe to view change end event

I'm trying to subscribe to the 'viewchangeend' event so I can grab the heading of the streetside map view. I can't seem to get anything to work. Any help would be appreciated. Thank you

So far I've tried:

<x-map #xmap [Options]="_options" (MapService)="onMapLoaded($event)"></x-map>
  onMapLoaded(event: BingMapService) {
    this.mapInstance = event.MapInstance;
    this.viewChangedEvent$ = event.SubscribeToMapEvent('viewchangeend');
    this.viewChangedEvent$.subscribe((viewChangeEvent) => {
      console.log('viewchange event heading', this.mapInstance.getHeading());
    });
  }

Error:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'add' of undefined
TypeError: Cannot read property 'add' of undefined
    at Function.n.addHandler (bd0074b3.js?bu=BO8E3wThAfQE:1)
    at angular-maps.js:15055
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388)
    at Object.onInvoke (core.js:3820)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (zone.js:138)
    at zone.js:872
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:3811)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
    at resolvePromise (zone.js:814)
    at zone.js:877
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:421)
    at Object.onInvokeTask (core.js:3811)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:420)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:188)
    at drainMicroTaskQueue (zone.js:595)

Q: Zoom in on click

Hi,

How can I zoom in on the maps when I click/select button or an asset to poplute a single location, I'm using bing maps (fetching the lat and long from a backend)? Is there any example that can be provided?

Cheers

Ali

Map not loading when populating markers and polylines with an empty list

In my code I have two separate lists that have objects with the information I need to make markers and polylines. My html (seen below) works great when I have any data, but as soon as my list is empty the map stops displaying. I would like to just display an empty map if I have no available data. Is there a reason the map is not displaying?

<div class="map">
  <x-map #xmap [Options]="options" [Latitude]="latitude" [Longitude]="longitude">
    <x-map-marker *ngFor="let loc of locationArray"
      [Latitude]="loc.latitudeNumber"
      [Longitude]="loc.longitudeNumber"
      [IconUrl]="'asset url'">
      <x-info-box
        [Title]="loc.SLIC"
        [Description]="'My Description">
      </x-info-box>
    </x-map-marker>
    <x-map-polyline *ngFor="let key of keyArray"
      [Path]="linkMap.get(key)[0].points"
      [StrokeWeight]=5
      [StrokeColor]="masterColor">
      <x-info-box *ngFor="let line of linkMap.get(key)"
        [Title]="My Title"
        [Description]="My Description">
      </x-info-box>
    </x-map-polyline>
  </x-map>
</div>

These are the values of the arrays when the map isn't displaying.

locationArray = [];
keyArray = [];

Marker layer Visible attribute doesn't work

Just like code below, Change [Visible] attribute doesn't take effect.

`
//our root app component
import {Component, NgModule, VERSION} from '@angular/core'
import {BrowserModule} from '@angular/platform-browser'
import {MapModule, MapAPILoader, BingMapAPILoaderConfig, BingMapAPILoader, MarkerTypeId, IMapOptions, IBox, WindowRef, DocumentRef, MapServiceFactory, BingMapServiceFactory } from 'angular-maps';

@component({
selector: 'my-app',
template: <i class="fa"></i> <div style="height: 600px"> <x-map #xmap [Options]="_options" [Box]="_box"> <x-map-marker-layer [Visible]="_layerVisible"> <x-map-marker *ngFor="let m of _markers; let i=index" [Latitude]="m.latitude" [Longitude]="m.longitude" [Title]="'My Marker ' + i.toString()" [IconInfo]="_iconInfo"> <x-info-box [DisableAutoPan]="true" [Title]="'My InfoBox ' + i.toString()" [Description]="'Hi, this is the content of the <strong>info window</strong>. It is your responsibility to implement functionality such as close, etc...'"> <x-info-box-action [Label]="'Click Me'" (ActionClicked)="_click(i)"></x-info-box-action> </x-info-box> </x-map-marker> </x-map-marker-layer> </x-map> </div>
})
export class App {
_layerVisible: boolean = false;
_markerTypeId = MarkerTypeId;
_options: IMapOptions = {
disableBirdseye: false,
disableStreetside: false,
navigationBarMode: 1,
zoom: 6
};

_box: IBox = {
maxLatitude: 32,
maxLongitude: -92,
minLatitude: 29,
minLongitude: -98
};

_iconInfo: IMarkerIconInfo = {
markerType: MarkerTypeId.CanvasMarker,
rotation: 45,
drawingOffset: { x: 12, y: 0 },
points: [
{ x: 5, y: 20 },
{ x: 12, y: 15 },
{ x: 19, y: 20 },
{ x: 12, y: 0 }
],
color: '#f00',
size: { width: 24, height: 24 }
};

_markers: Array = new Array();

constructor() {
this._markers.push({ latitude: 29.714994, longitude: -95.46244})
for(let i:number=0; i<20; i++){
this._markers.push({ latitude: 29.714994 + Math.random() - Math.random(), longitude: -95.46244 + Math.random() - Math.random()});
}
}

_click(index: number){
console.log(Marker ${index} says: hello world...);
}
}

@NgModule({
imports: [
BrowserModule,
MapModule.forRoot()
],
declarations: [ App ],
providers: [
{
provide: MapAPILoader, deps: [], useFactory: MapServiceProviderFactory
}
],
bootstrap: [ App ]
})
export class AppModule {}

export function MapServiceProviderFactory(){
let bc: BingMapAPILoaderConfig = new BingMapAPILoaderConfig();
bc.apiKey ="Ap0AObt84NcDaUThCeWOj52ZqUHv6k4TJhjLibR-DghC-semgoj-0uPbIi8r0E4j";
// replace with your bing map key
// the usage of this key outside this plunker is illegal.
bc.branch = "";
// to use the experimental bing brach. There are some bug fixes for
// clustering in that branch you will need if you want to use
// clustering.
return new BingMapAPILoader(bc, new WindowRef(), new DocumentRef());
}
`

Bing Map in Modal

Hi there!
Did someone try to show Bing map with markers in the modal-window? I see an issue in the console when modal-window is closed.

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'draggable' of null
TypeError: Cannot read property 'draggable' of null
    at r.setOptions (d98b7733.js?bu=rms+answers+Maps+AnonymousBegin*SDKPluginStart*SDKInfoboxOverlay*Infobox*SDKColor*Ti…:1)
    at BingMarker.webpackJsonp.../../../../angular-maps/dist/src/models/bing/bing-marker.js.BingMarker.DeleteMarker (bing-marker.js:126)
    at bing-marker.service.js:137
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.es5.js:3890)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (zone.js:141)
    at NgZone.webpackJsonp.../../../core/@angular/core.es5.js.NgZone.run (core.es5.js:3821)
    at bing-marker.service.js:136
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at r.setOptions (d98b7733.js?bu=rms+answers+Maps+AnonymousBegin*SDKPluginStart*SDKInfoboxOverlay*Infobox*SDKColor*Ti…:1)
    at BingMarker.webpackJsonp.../../../../angular-maps/dist/src/models/bing/bing-marker.js.BingMarker.DeleteMarker (bing-marker.js:126)
    at bing-marker.service.js:137
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at Object.onInvoke (core.es5.js:3890)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:390)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.run (zone.js:141)
    at NgZone.webpackJsonp.../../../core/@angular/core.es5.js.NgZone.run (core.es5.js:3821)
    at bing-marker.service.js:136
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:391)
    at resolvePromise (zone.js:783)
    at zone.js:834
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:424)
    at Object.onInvokeTask (core.es5.js:3881)
    at ZoneDelegate.webpackJsonp.../../../../zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Zone.webpackJsonp.../../../../zone.js/dist/zone.js.Zone.runTask (zone.js:191)
    at drainMicroTaskQueue (zone.js:595)
    at webpackJsonp.../../../../zone.js/dist/zone.js.ZoneTask.invokeTask (zone.js:502)
    at ZoneTask.invoke (zone.js:487)
    at timer (zone.js:1829)

Is there a way to create a custom html infoBox?

In the Bing Maps library there is an htmlContent attribute to infoBoxes that lets you use custom html. I don't see this attribute as part of x-map-marker? Is there a different way of doing this, or does this feature need to be added?

Bing/General - How to detect if a geolocation is visible on the map?

I have a display list that's dependent on which map markers / pins are currently in map boundaries.

Trivial bounds checking logic (marker location.min > map boundary.min && marker location.max < map boundary.max etc) filters items at certain panning and zoom levels whose map markers are visible.

I figured this would be trivial to solve, but looking at the boundaries vs the map and marker locations, I can't seem to pin my finger on a sure-fire way to detect if map markers are (or should be) in visible range or not.

Is there a helper function or algorithm to detect if a location is currently visible on the map?

MapModule import error

Hi there!

I'm trying to import MapModule into my app module

@NgModule({
imports: [
MapModule.forRoot()

but it causes the following error:

ERROR in Error encountered resolving symbol values statically. Function calls are not supported. Consider replacing the
function or lambda with a reference to an exported function (position 194:50 in the original .ts file), resolving symbol
NgModule in /node_modules/angular-maps/node_modules/@angular/core/core.d.ts, resolving sym
bol MapModule in /node_modules/angular-maps/dist/index.d.ts, resolving symbol MapModule in
/node_modules/angular-maps/dist/index.d.ts

Any ideas how to make it work?

Thanks!

Difficulty displaying BingMap through Angular Route

Hi There,

I'm in need of a bit of help...

I am trying to use the following example of yours 'Bing Map with Font Based Marker (use any icon font)' and I do get it to display properly when I do a new Angular project, but if a integrate it into an existing project of mine using a 'Route' directive, I do not seem to get the Map to display upon load. I get the box size of the map on the screen, but no map and no errors being displayed.

My 'map.component.ts', 'map.component.html', 'map.component.scss' and 'map.route.ts' is nested in a directory called 'entities' and the 'entities' directory is nested in my 'app' directory.

I have a 'entity.route.ts' which imports the 'map.route.ts' and then exports it to 'entity.module.ts' which is then imported into my ' app.module.ts'.

I have the same code in my 'app.module.ts' as you have, and also the same code as you have in my 'map.component.ts', 'map.component.html', 'map.component.scss' files.

Your 'index.html' link for font-awesome I have placed in the 'head' tags of my 'index.html' file, and in the 'body' of my 'index.html' file, I call my open and closing 'main' '/main' tag directives where I have my opening and closing 'router-outlet' '/router-outlet' tags in my 'main.component.html' file which receives the BingMap but does not render it.

I don't know if I've missed something, somewhere... would you be able to please help me with this issue?

Thank you

How to get BingMap instance reference?

Hi there,

I would like to work on bing map directly after it is created. How can I get the reference?

Tried BingMapService, it's MapInstance is undefined.

Thanks for your help!

Yelong

Cannot find namespace 'Microsoft'

Hi,

I'm getting an error, TS2503: Cannot find namespace 'Microsoft'.

ERROR in node_modules/angular-maps/src/models/bing/bing-canvas-overlay.d.ts(28,32): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-canvas-overlay.d.ts(35,15): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-canvas-overlay.d.ts(60,17): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-cluster-layer.d.ts(44,25): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-cluster-layer.d.ts(95,34): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-cluster-layer.d.ts(119,40): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-info-window.d.ts(26,30): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-info-window.d.ts(32,27): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-layer.d.ts(33,25): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-marker.d.ts(12,21): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-marker.d.ts(13,23): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-marker.d.ts(58,27): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-marker.d.ts(58,57): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-marker.d.ts(58,85): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polygon.d.ts(13,23): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polygon.d.ts(58,30): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polygon.d.ts(90,27): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polygon.d.ts(90,88): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polyline.d.ts(11,21): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polyline.d.ts(12,23): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polyline.d.ts(36,30): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polyline.d.ts(60,28): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polyline.d.ts(60,59): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-polyline.d.ts(60,87): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/models/bing/bing-spider-cluster-marker.d.ts(7,12): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/services/bing/bing-map.service.d.ts(48,27): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/services/bing/bing-map.service.d.ts(55,34): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/services/bing/bing-map.service.d.ts(186,59): error TS2503: Cannot find namespace 'Microsoft'.
node_modules/angular-maps/src/services/bing/bing-polyline.service.d.ts(67,32): error TS2503: Cannot find namespace 'Microsoft'.

Here's my angular project version

Angular CLI: 7.1.0
Node: 10.13.0
OS: linux x64
Angular: 7.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.10.7
@angular-devkit/build-angular 0.10.7
@angular-devkit/build-optimizer 0.10.7
@angular-devkit/build-webpack 0.10.7
@angular-devkit/core 7.0.7
@angular-devkit/schematics 7.1.0
@angular/cli 7.1.0
@ngtools/webpack 7.0.7
@schematics/angular 7.1.0
@schematics/update 0.11.0
rxjs 6.3.3
typescript 3.1.6
webpack 4.19.1

I'm just trying to display a basic bing maps component on the localhost and I followed installation instructions on your npm page.

Google Maps Marker labelOrigin option is missing

I try to set the label position to make it displayed above the marker icon in Google Maps but it seems this option is missing from current version.
What I want to setup is something like this in plain javascript:

var marker = new google.maps.Marker({
	position:{lat: item.lat, lng:item.lng},
	label: {
		text: item.phone,
		color: '#000',
		fontWeight: 'bold',
		fontSize: "11px"
	},
	icon:{
		url: "/images/final_images/hotline.png",
		labelOrigin: new google.maps.Point(22, -8)
	}
});

labelOrigin allows us to set the label position. Please show me guide to add this option in angular-maps package.

Thanks and best regards,
Dat

How to change the center of the map after loaded?

Basically the title.

I want to be able to dynamically change where the map is centered after it has been loaded. My user will provide input and I want to change the map center so that the markers and polylines displayed on the map are in view. How do I go about this?

Is there a way to give certain markers priority over others?

For example, when zoomed out and two markers overlap each other, I would like for one to always overlap the other, but I don't see a way to set this. Here is my html. I would like to put the marker within the polyline with less priority than the other marker.

<div class="map">
  <x-map #xmap [Options]="options" [Latitude]="latitude" [Longitude]="longitude">
    <x-map-marker *ngFor="let loc of locationArray"
      [Latitude]="loc.latitudeNumber"
      [Longitude]="loc.longitudeNumber"
      [IconUrl]="'../../../assets/Images/ups_hub.png'">
      <x-info-box
        [Title]="'Title'"
        [Description]="''My Description'">
      </x-info-box>
    </x-map-marker>
    <x-map-polyline *ngFor="let key of keyArray"
      [Path]="linkMap.get(key)[0].points"
      [StrokeWeight]=5
      [StrokeColor]="masterColor">
      <x-map-marker
        [Latitude]="linkMap.get(key)[0].arrowLatitude"
        [Longitude]="linkMap.get(key)[0].arrowLongitude" 
        [IconInfo]="linkMap.get(key)[0].options">
      </x-map-marker>
      <x-info-box *ngFor="let link of linkMap.get(key)"
        [Title]="'Title'"
        [Description]="'My Description'>
      </x-info-box>
    </x-map-polyline>
  </x-map>
</div>

Bing Maps Polyline and Map Marker

When using map-markers and polylines with bing maps, if I have a dataset that is a decent size (200+ items in the list) the map takes a very long time to load the polylines and map-markers. Is there anyway to improve this speed?

Typo

MarkerTypeId.DynmaicCircleMarker
should be:
MarkerTypeId.DynamicCircleMarker

Bing Maps - interaction with x-info-box

Hi @thor-schueler!
I see that you added new mouse events for map-markers and this is great!
But how can I show/hide info-box from this event?
Tried to use InfoBoxService and MarkerService, but as I can see the new instance of services is provided in the component, and I can't change the Visible value of info-box.

Thanks for any advice!

Several IMapOptions are not working

There are several option of IMap which are not working like
showMapTypeSelector: false,
disableZooming: true

Could you please look into it?

Bings Route Direction Directive for the Driving path

Hi @thor-schueler Do we have any wrapper for native direction service of bings map to get the driving route?I tried creating the directive to do it but ran into "Microsoft not defined issue" even though i included the triple slash directive import.Do we have to generate the route data and call polyline directive.I'm new to bings and angular 4.Thanks

Using angular-maps

I followed the three steps in Use section and tried various things without much luck. The error code I get when trying to implement bing-maps component in my angular project is:

Uncaught Error: Template parse errors:
Can't bind to 'Latitude' since it isn't a known property of 'map-marker'.
1. If 'map-marker' is an Angular component and it has 'Latitude' input, then verify that it is part of this module.
2. If 'map-marker' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
  <x-map #xmap [Options]="_options">
      <map-marker
          [ERROR ->][Latitude]="30" 
          [Longitude]="90" 
          [Title]="'My Marker'" 
"): ng:///AppModule/BingMapComponent.html@6:10
Can't bind to 'Longitude' since it isn't a known property of 'map-marker'.

Were there additional imports necessary for bing-map component that I created?
Also I tried having the line

///<
reference path="../../../node_modules/bingmaps/types/MicrosoftMaps/Microsoft.Maps.All.d.ts" />

at the top of the bing-map component

Bing Maps Search

Hi there,

Do you have any sample with Bing Maps and the Search Manager (Microsoft.Maps.Search) implemented ?

Thanks for your help!
-NC

Cannot find namespace 'Microsoft'.

Hi @thor-schueler, I am getting this issue.

E:/Tyco/project/working-copy/TYC023/tyco-web/angular-master/node_modules/angular-maps/dist/src/models/bingMaps/binginfowindow.d.ts(7 ,27): error TS2503: Cannot find namespace 'Microsoft'.
E:/Tyco/project/working-copy/TYC023/tyco-web/angular-master/node_modules/angular-maps/dist/src/models/bingMaps/binglayer.d.ts(32,25) : error TS2503: Cannot find namespace 'Microsoft'.
E:/Tyco/project/working-copy/TYC023/tyco-web/angular-master/node_modules/angular-maps/dist/src/models/bingMaps/bingmarker.d.ts(63,27 ): error TS2503: Cannot find namespace 'Microsoft'.
E:/Tyco/project/working-copy/TYC023/tyco-web/angular-master/node_modules/angular-maps/dist/src/models/bingMaps/bingspiderclustermark er.d.ts(7,12): error TS2503: Cannot find namespace 'Microsoft'.
E:/Tyco/project/working-copy/TYC023/tyco-web/angular-master/node_modules/angular-maps/dist/src/services/bingMaps/bingmapservice.d.ts (40,27): error TS2503: Cannot find namespace 'Microsoft'.
E:/Tyco/project/working-copy/TYC023/tyco-web/angular-master/node_modules/angular-maps/dist/src/services/bingMaps/bingmapservice.d.ts

CanvasMarker - HowTo

Hi

Do you have an example on how to use CanvasMarker? Can you post it? It will be very helpful

Regards,
Evgeny

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.