Skip to content

Show current location functionality with circle around the location #118

Open

Description

@ElesGergo

Hello,
What I am trying to achieve is a 'show current positon' fuction on bing maps with an accuracy circle drawn around it.

Steps:

1.Get the device current position from the web api which return the current latitude and logitude with the accuracy radious and bbox.

(Step one solution is simply to use window.navigator.geolocation functioins)

2.Draw a polygon (circle) around the the position as big as the the radious in meters.

(How to calculate the points required? )

3.A button over the map which sets the map around the current bbox.

My idea for the implementatioin is to get the boundsChange event from the map to query data for the markers based on bbox.(the base for every live map app) My problem is that the box property of the map does not get updated when the boundsChange event fires so it is not possible to set the map screen back more than once since the box property stays the same even tho the map screen is at another location. (I tryed to set it to null and undefined it does not seemd to work)
Any suggestions for this?

This question maybe would better fit for stackoverflow, tho I thought that it is some basic functionality for live maps using device positions, so I thought it could benefit others as well.

Activity

  1. changed the title [-]Draw circle around around current location with added padding[/-] [+]Draw circle around around current location [/+] on Oct 30, 2019
  2. changed the title [-]Draw circle around around current location [/-] [+]Show current location functionality with circle around the location[/+] on Oct 30, 2019
  3. thor-schueler commented on Nov 1, 2019

    @thor-schueler
    Contributor

    There are a few things here:

    • obtain current location: yes i'd say use the geolocation function. now, there might be some trickiness with AOT, since this is a browser function and therefore not available outside the browser. Just be aware of that.
    • circle support (which is on the list of things to do, there is a project for that). For the time being, you can simply calculate a polygon with 720 points (one for each half rad), that should be sufficiently smooth. Simple trigonometry, keep the radius constant, advance the angle, that gives you the lat/long offsets for each point. There is probably an algorithm out there on stackoverflow I'd think.

    I don't quite understand your point under 3 though. the [Box] property is an input, so yes, it does not get changed as the map zooms. However, the (BoundsChange) event gives you the new box whenever the zoom changes or the bounds change. So you can use that to update your box variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions