Setting Boundaries around city in google maps

后端 未结 3 1805
生来不讨喜
生来不讨喜 2021-01-03 16:27

I\'m looking for a way to set boundaries around a specific city/town within the Google maps API V3 using JavaScript

Is this type of thing even supported within the A

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 16:34

    You need to get the points for boundries of the city, then you can create a polyline. For example, one idea could be similar to this:

    limitCoord = [
        new google.maps.LatLng(42.49956716,-7.019005501),
        new google.maps.LatLng(42.49947126,-7.029286373),
        new google.maps.LatLng(42.50904062,-7.049299123),
        new google.maps.LatLng(42.50722622,-7.069103626),
        new google.maps.LatLng(42.50452387,-7.000150672),
        new google.maps.LatLng(42.49348015,-6.983058917),
        new google.maps.LatLng(42.49843269,-6.971666546),
        new google.maps.LatLng(42.51765791,-6.956909023),
        new google.maps.LatLng(42.52010069,-6.927429186),
        new google.maps.LatLng(42.50992238,-6.914231493),
        new google.maps.LatLng(42.50096695,-6.879679821),
        new google.maps.LatLng(42.48775868,-6.857775832),
        new google.maps.LatLng(43.23907504,-3.293216584)], "#000000", 5);
    
    var boundries = new google.maps.Polyline({
        path: limitCoord,
        strokeColor: "#000000",
        strokeOpacity: 1.0,
        strokeWeight: 2
    });
    

提交回复
热议问题