What I would like to do is pull the latitude and longitude values from a database and show them on a google map with polygon lines
The polygon lines have been successfully created, but I would like to have this polygon line appear with zoom when clicking on a particular project from the database
This is my project table
ID
Project name
lat
lng
description
This is my land piece coord table
ID
project_id
lat
lng
I want to place my project on a map, so that when someone clicks the project, they see the land piece and its specifics
the code i already tried is https://www.webwiders.in/WEB01/cluster/
This is my controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Site extends CI_Controller {
public function __construct() {
parent::__construct();
$this->db->query("set sql_mode = ''");
}
public function index(){
$this->load->view('site/index');
}
?>
This is my view
<!DOCTYPE >
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>MarkerClustererPlus V3 Example</title>
<style type="text/css">
body {
margin: 0;
padding: 10px 20px 20px;
font-family: Arial;
font-size: 16px;
}
#map-container {
padding: 6px;
border-width: 1px;
border-style: solid;
border-color: #ccc #ccc #999 #ccc;
-webkit-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
-moz-box-shadow: rgba(64, 64, 64, 0.5) 0 2px 5px;
box-shadow: rgba(64, 64, 64, 0.1) 0 2px 5px;
width: 600px;
}
#map {
width: 600px;
height: 400px;
}
</style>
<script src="https://maps.googleapis.com/maps/api/js?
key=yourkey"></script>
<script type="text/javascript" src="<?= base_url() ?>assets/js/data.js"></script>
<script src="https://unpkg.com/@googlemaps/markerclustererplus/dist/index.min.js"></script>
<script type="text/javascript">
<?php $properties = $this->common_model->GetAllData('properties' , '' , 'id' , 'desc');
?>
function initialize() {
var center = new google.maps.LatLng(28.079872, 78.357087);
var map = new google.maps.Map(document.getElementById("map"), {
zoom: 3,
center: center,
mapTypeId: google.maps.MapTypeId.ROADMAP,
});
var markers = [];
<?php foreach ($properties as $row)
{
$lands = $this->common_model->GetAllData('land_marks' , array('p_id' => $row['id'] ),
'id' , 'desc');
?>
var data = [];
<?php
foreach ($lands as $value)
{ ?>
var feed = {lat: <?= $value["lat"] ?> , lng:<?= $value["lng"] ?> };
data.push(feed);
var latLng = new google.maps.LatLng(
'<?= $value["lat"] ?>',
'<?= $value["lng"] ?>'
);
var marker = new google.maps.Marker({
position: latLng,
});
markers.push(marker);
<?php }
?>
const bermudaTriangle<?= $row["id"] ?> = new google.maps.Polygon({
paths: data,
strokeColor: "#FF0000",
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: "#FF0000",
fillOpacity: 0.35,
});
bermudaTriangle<?= $row["id"] ?>.setMap(map);
var markerCluster<?= $row["id"] ?> = new MarkerClusterer(map, markers , {
imagePath:
"<?= base_url() ?>assets/images/m",
});
<?php
}
?>
}
google.maps.event.addDomListener(window, "load", initialize);
</script>
</head>
<body>
<h3>A simple example of MarkerClustererPlus (100 markers)</h3>
<div id="map-container"><div id="map"></div></div>
</body>
</html>