-2

var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 20,
    center:this.cityHallLocation ,
    disableDefaultUI : true,
    styles:[{"featureType":"landscape","stylers":[{"hue":"#FFBB00"},{"saturation":43.400000000000006},{"lightness":37.599999999999994},{"gamma":1}]},{"featureType":"road.highway","stylers":[{"hue":"#FFC200"},{"saturation":-61.8},{"lightness":45.599999999999994},{"gamma":1}]},{"featureType":"road.arterial","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":51.19999999999999},{"gamma":1}]},{"featureType":"road.local","stylers":[{"hue":"#FF0300"},{"saturation":-100},{"lightness":52},{"gamma":1}]},{"featureType":"water","stylers":[{"hue":"#0078FF"},{"saturation":-13.200000000000003},{"lightness":2.4000000000000057},{"gamma":1}]},{"featureType":"poi","stylers":[{"hue":"#00FF6A"},{"saturation":-1.0989010989011234},{"lightness":11.200000000000017},{"gamma":1}]}],
});

var marker = new google.maps.Marker({
    position: this.cityHallLocation,
    map: map,
});

How to determine if I am on the right radius in google maps. Like for example I want the specific radius for 20 from in a specific location and I want to determine if I am on that 20m then show the marker on that location. Sorry I am new to google maps.

jostrander
  • 745
  • 5
  • 18
TheBAST
  • 2,680
  • 10
  • 40
  • 68
  • 1
    This is not a google-maps nor a Vue.js question. If you want to do this from a center point which is already known before you initiate google-maps, then you should calculate your radius in the backend. This can be done by using the Haversine formula. – Stephan-v Feb 16 '18 at 12:17
  • @Stephan-v, It's not a vuejs question but I'm using vuejs on this. SO I included it. What I want is to draw a specific radius in the map. – TheBAST Feb 16 '18 at 12:59
  • Then calculate your radius in your backend before you initiate Google Maps and apply only those markers. – Stephan-v Feb 16 '18 at 14:17
  • Possible duplicate of [Draw radius around a point in Google map](https://stackoverflow.com/questions/825794/draw-radius-around-a-point-in-google-map) – Mackija Feb 16 '18 at 15:11

2 Answers2

1

You need use library geolib or alternative lib https://www.npmjs.com/package/geolib

geolib.isPointInCircle(object latlng, object center, integer radius)

example

// checks if 51.525, 7.4575 is within a radius of 5km from 51.5175, 7.4678
geolib.isPointInCircle(
    {latitude: 51.525, longitude: 7.4575},
    {latitude: 51.5175, longitude: 7.4678},
    5000
);
Igor Ognichenko
  • 276
  • 2
  • 14
0

isPointInCircle renamed to isPointWithinRadius reference : https://www.npmjs.com/package/geolib

  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 02 '23 at 12:59