Create a circle surrounding the latitude and longitude on a Bing Maps angular display

I successfully integrated the Bing map with Angular using the angular-map package, and now I want to draw a circle around a given latitude and longitude. To achieve this, I installed the following npm packages:

  • npm install --save angular-maps
  • npm install --save bingmaps
  • npm install --save @types/bingmaps
  • npm install --save [email protected]
  • npm install --save json-loader

app.component.ts

import { Component, OnInit } from '@angular/core';
import { LocalStorageService } from 'src/app/service/local-storage.service';
import { LOCATION_INITIALIZED } from '@angular/common';
import { TranslateServiceService } from 'src/app/service/translate-service.service';

import {
  MapModule, MapAPILoader, MarkerTypeId, IMapOptions, IBox, IMarkerIconInfo, WindowRef, DocumentRef, MapServiceFactory,
  BingMapAPILoaderConfig, BingMapAPILoader,
  GoogleMapAPILoader, GoogleMapAPILoaderConfig
} from 'angular-maps';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'rj';
  lat: string;
  long: string;
  constructor(
    private localStorageService: LocalStorageService,
    private translateServiceService: TranslateServiceService) {

  }
  ngOnInit(): void {
    this.lat = '18.5204';
    this.long = '73.8567';
    this.checkLanguagePerferences();
  }
  checkLanguagePerferences() {
    const language = this.localStorageService.getLanguage();
    if (language) {
      this.translateServiceService.selectLangulage(language);
    }
  }

  
  _markerTypeId = MarkerTypeId;
  _options: IMapOptions = {
    disableBirdseye: false,
    disableStreetside: false,
    navigationBarMode: 1,
    showBreadcrumb: true,
    // zoom: 10
  };

  _box: IBox = {
    maxLongitude: null,
    maxLatitude: null,
    minLatitude: 20,
    minLongitude: 64
  };
  
  public _iconInfo: IMarkerIconInfo = {
    markerType: MarkerTypeId.RoundedImageMarker,
    url: 'https://cdn3.iconfinder.com/data/icons/flat-icons-web/40/Location-512.png',
    size: { width: 40, height: 40 },
    markerOffsetRatio: { x: 0.5, y: 0.5 }
  };

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

App.component.html

<i class="fa"></i>
            <div style="height: 600px" class="col-sm-6 col-md-6 col-lg-6">
              <x-map #xmap [Options]="_options">
                <x-map-marker 
                  [Latitude]=lat 
                  [Longitude]=long
                  [Title]="'My Marker'"
                  [IconInfo]="_iconInfo">
                    <x-info-box
                      [DisableAutoPan]="true"
                      [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()"></x-info-box-action>
                    </x-info-box>
                </x-map-marker>
              </x-map>
            </div>

Issue: Unable to create a circle around the map marker.

Answer №1

Currently, the official 'angular-maps' npm website states that there is no built-in support for drawing circles.

A suggestion in this discussion thread proposes using the native Microsoft.Maps.SpatialMath.getRegularPolygon function to create a polygon and then convert it into an array of ILatLong coordinates to be used as [Paths] on the x-map-polygon element.

We apologize for not providing a direct solution to this issue. If you have found an alternative solution, please share it with us.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Testing the integration of socket.io with Angular through unit tests

Currently, I am in the process of unit testing an angular service within my application that is responsible for creating a socket.io client. The structure of my service can be seen below: export class SocketService { private name: string; private host ...

What causes the discrepancy in values displayed by enums in TypeScript when assigned integers in reverse order?

Recently diving into the world of TypeScript, I've been experimenting with different types in this language. One interesting data type I played with is enums. Here's an example of code I used: enum colors {red=1,green=0,blue,white}; console.lo ...

What steps should I take to enable the camera view in ngx-scanner?

I am currently working on an app that utilizes a QR code scanner. To implement this, I am using the ngx-scanner component, which is a modified version of Google's ZXing scanning library designed for Angular. However, I am encountering an issue where ...

When attempting to compile Typescript code, error TS1128 occurs indicating a missing declaration or statement. However, the code functions correctly when executed through a server

Currently, I'm in the process of developing a project using Angular2. As part of this project, I have created a primary Component class which serves as a central piece: import { Component, OnInit} from '@angular/core'; import { submitServi ...

Develop customizable enumerations for use in expandable interfaces

Situation: My objective is to devise a strategy for building scalable state machines in TypeScript using the TypeState library. TypeState offers a typesafe state machine for Typescript, which while not directly related to my current issue, serves as a good ...

The test suite encountered an error (EBUSY: resource busy or locked) and unfortunately failed to run at Nx version 14.5.10 and Jest version 27.5.1. It seems there was an

I have recently upgraded my NX Monorepo from version 13 to 14, and everything seems to be working fine except for the Jest migration. I keep encountering this error even after trying various solutions like clearing the cache, deleting node_modules, and rei ...

Is Angular UI's data binding more of a push or pull mechanism? How can I optimize its speed?

Suppose I have a variable a that is displayed in HTML as {{a}}. If I then update its value in TypeScript using a = "new value";, how quickly will the new value be reflected in the user interface? Is there a mechanism that periodically checks all bound var ...

Error in TypeScript when using keyof instead of literal in type pattern.Beware of TypeScript error when not

let c = { [X in keyof { "foo" }]: { foo: "bar" } extends { X } ? true : false }["foo"]; let d = { foo: "bar" } extends { "foo" } ? true : false; c and d should both return true, but surprisingly, c is eval ...

Comparing strings with data in objects using Angular

all. I have a query. What is the optimal method for comparing data? For instance, if you have a constant response = 225235743; And I aim to locate and exhibit all data in an object with the same ID as the one in this response. This needs to be resolved ...

Is there a better approach to verifying an error code in a `Response` body without relying on `clone()` in a Cloudflare proxy worker?

I am currently implementing a similar process in a Cloudflare worker const response = await fetch(...); const json = await response.clone().json<any>(); if (json.errorCode) { console.log(json.errorCode, json.message); return new Response('An ...

AngularJS is encountering issues with dependency injections when using WebStorm and TypeScript

A TypeScript AngularJS component: class MyComponentCtrl { static $inject = ['MyService']; constructor(private MyService) { MyService.testfn(55); // No error in typescript } } class MyComponent implements ng.IComponentOptions { ...

How to display the Y axis value on the category axis in a solid gauge using amcharts

My Code : <div id="chartdiv"></div> Styling : #chartdiv { width: 100%; height: 200px; } Script: am4core.useTheme(am4themes_animated); var chart = am4core.create("chartdiv", am4charts.RadarChart); chart.data = [{ ...

The Ionic serve command fails to recognize and reflect any saved changes, leading to a lack of automatic reloading

Recently, I encountered a strange issue while using my ionic 2 application. Whenever I execute the ionic serve command, it launches the server on localhost and produces the following output: [12:00:45] ionic-app-scripts 0.0.45 [12:00:46] watch started ...

Hold off on proceeding until the subscription loop has finished

Is there a way to verify that all results have been successfully pushed to nodesToExpand after running the for loop? The getFilterResult function is being called via an HTTP request in the nodeService service. for(var step in paths) { this.nodeSe ...

Verify two asynchronous boolean variables and trigger a function if both conditions are met

Is there a way to enhance the rendering process so that the renderFilters() method is only called when both variables are true: These two variables are loaded asynchronously through 2 API methods: //getManager() this.isLoadingManager = true; //getPdiPOrg ...

Using *ngFor with a condition in Angular 4 to assign different values to ngModel

I am new to Angular 4 and encountering an issue with using *ngFor in conjunction with HTML drop-down select and option elements. My categories array-object looks like this - categories = [ { id:1, title: 'c/c++'}, { id:2, title: 'JavaScri ...

What are the steps to execute jest in an AWS Lambda environment?

I'm looking to execute my end-to-end test post-deployment for the ability to revert in case of any issues. I've followed the guidelines outlined in this particular blog post. Below is my lambda function: export async function testLambda(event: A ...

Having trouble rendering Next.JS dynamic pages using router.push()? Find out how to fix routing issues in your

The issue I am facing revolves around the visibility of the navbar component when using route.push(). It appears that the navbar is not showing up on the page, while the rest of the content including the footer is displayed. My goal is to navigate to a dy ...

Switching from dark mode to light mode when reloading or navigating to a new page

Hello everyone. I've successfully implemented a dark mode toggle on my website, but I'm facing an issue where the mode resets whenever I navigate to a new page or refresh the current page. Can anyone help me figure out how to prevent this from ...

Conceal API request details on the network tab

I am currently working on an application built with Angular 10. I was wondering if there is a way to encrypt the request parameters or hide sensitive data. The issue is that anyone who can view the URL has access to both the Bearer token and the request pa ...