【发布时间】:2019-08-04 23:51:41
【问题描述】:
我希望位置变量从数据库中获取经度和纬度并显示它们的集群 请在这方面需要帮助我希望从具有存储这些数据的表的数据库中获取所有经度和纬度
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 3,
//mkoa wa dodoma location
center: {lat: -6.1630, lng: 35.7516}
});
// Create an array of alphabetical characters used to label the markers.
var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
// Add some markers to the map.
// Note: The code uses the JavaScript Array.prototype.map() method to
// create an array of markers based on a given "locations" array.
// The map() method here has nothing to do with the Google Maps API.
var markers = locations.map(function(location, i) {
return new google.maps.Marker({
position: location,
label: labels[i % labels.length]
});
});
// Add a marker clusterer to manage the markers.
var markerCluster = new MarkerClusterer(map, markers,
{imagePath: 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/m'});
}
//kwajiri ya miji
var locations = [
{lat: -6.1730, lng: 35.7516},
{lat: -6.2330, lng: 35.7523},
{lat: -6.2330, lng: 35.7523},
{lat: -6.2330, lng: 35.7523},
{lat: -6.2330, lng: 35.7523},
{lat: -6.1730, lng: 35.7516},
{lat: -6.1730, lng: 35.7516},
{lat: -7.773094,lng: 35.699120},
{lat: -7.773094,lng: 35.699120},
{lat: -7.773094,lng: 35.699120},
{lat: -5.030461,lng: 32.819431},
{lat: -5.030461,lng: 32.819431},
{lat: -5.030461,lng: 32.819431},
{lat: -5.030461,lng: 32.819431},
{lat: -8.909401,lng: 33.460773},
{lat: -8.909401,lng: 33.460773},
{lat: -8.909401,lng: 33.460773},
{lat: -6.802353,lng: 39.279556},
{lat: -6.802353,lng: 39.279556},
{lat: -6.802353,lng: 39.279556},
{lat: -6.802100,lng: 39.279119},
{lat: -6.1730, lng: 35.7516}
]
</script>
如你所见,变量位置在数组中
【问题讨论】:
-
你的问题不完整,告诉我们你到目前为止做了什么,你想用它做什么。
-
我已经更新了,请检查
-
您必须提供表格样本以及经纬度数据存储在表格中的方式,以及您的 PHP 代码。它是 javascript 你在使用 AJAX 吗?或者您想在发布表单后获取。
-
我想使用 Ajax 从数据库中获取数据,但是数据库中的结构具有 ID LONGITUDE LATITUDE
-
我只想修改变量位置只有 long 和 lat 不能是静态的我希望变量从数据库中获取这些字段@SayedMohdAli
标签: javascript php json mysqli