1
예를 들어 위도와 경도가 포함 된 MySQL 데이터베이스가 있는데이 좌표를지도에 표시하려면 어떻게해야합니까? 누구든지 내가 도와 줄 수 있니?Yii에서 EGmap 확장을 위해 MySQL DB를 사용하는 방법
예를 들어 위도와 경도가 포함 된 MySQL 데이터베이스가 있는데이 좌표를지도에 표시하려면 어떻게해야합니까? 누구든지 내가 도와 줄 수 있니?Yii에서 EGmap 확장을 위해 MySQL DB를 사용하는 방법
질문과 정보를 조금 불분명하기 때문에, 이러한 나의 가정은 다음과 같습니다
(데이터베이스 테이블 및 열을 줄에 맞게 조정하십시오. "// 테이블 위치에서 LatLong 가져 오기"참조). 이 파일을 view 파일에 직접 넣으십시오 : protected/views/site/index.php
<!-- other html codes here -->
<div id="map-container">
<?php
// Get LatLong from table Location
$location=Location::model()->findByPk(1);
$latitude = $location->latitude;
$longitude = $location->longitude;
Yii::import('ext.gmap.*');
$gMap = new EGMap();
$gMap->setJsName('map');
$gMap->zoom = 10;
$mapTypeControlOptions = array(
'sensor'=>true,
'position'=> EGMapControlPosition::LEFT_BOTTOM,
'style'=>EGMap::MAPTYPECONTROL_STYLE_DROPDOWN_MENU
);
// Map settings
$gMap->mapTypeControlOptions= $mapTypeControlOptions;
$gMap->setWidth(800);
$gMap->setHeight(600);
$gMap->setCenter($latitude, $longitude);
// Prepare icon
$icon = new EGMapMarkerImage("http://google-maps-icons.googlecode.com/files/gazstation.png");
$icon->setSize(32, 37);
$icon->setAnchor(16, 16.5);
$icon->setOrigin(0, 0);
// Prepare marker
$marker = new EGMapMarker($latitude, $longitude, array('title' => 'Gas Station','icon'=>$icon));
$gMap->addMarker($marker);
$gMap->renderMap();
?>
</div>
<!-- other html codes here -->
대단히 감사합니다. osh, 코드를 사용해 보겠습니다 : D – dulharjo