Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm looking for some ways but I'm having a lot of difficulty ... I just need the information that is in "coordinates" and put it in a PHP

<script>
        mapboxgl.accessToken = 'MY_KEY :3';
    
        var client = new MapboxClient(mapboxgl.accessToken);
    
        var address = 'white house';
        var test = client.geocodeForward(address, function(err, data, res) {
    
    
          var coordinates = data.features[0].center;
 
          document.write(coordinates);
          //console.log(coordinates);
     
          var map = new mapboxgl.Map({
            container: 'map',
            style: 'mapbox://styles/mapbox/streets-v10',
            center: coordinates,
            zoom: 14
          });
          new mapboxgl.Marker()
            .setLngLat(coordinates)
            .addTo(map);
        });
    
      </script>
    </head>  
    <body>
      <div id='map'></div>
    </body>

A very simple example is this

<?php $coord = 'coordinates'; ?>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

I do not know what you want to calculate but there are all kinds of API's that you can use with php.

e.g. convert an address to the coordinates..

MAPBOX API for Geocoding: https://docs.mapbox.com/help/how-mapbox-works/geocoding/

Google Maps is an alternative solution: https://developers.google.com/maps/documentation/

https://developers.google.com/maps/documentation/geocoding/overview


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...