2012-05-18 2 views

답변

2

질문과 정보를 조금 불분명하기 때문에, 이러한 나의 가정은 다음과 같습니다

  1. 내가 제대로 지시를 따랐다 당신의 YII 응용 프로그램에 EGMap 확장을 설치하는 것으로 가정합니다.
  2. 위의 좌표 (위도 & 경도)에 표식을 배치하려고합니다.

(데이터베이스 테이블 및 열을 줄에 맞게 조정하십시오. "// 테이블 위치에서 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 --> 
+0

대단히 감사합니다. osh, 코드를 사용해 보겠습니다 : D – dulharjo

관련 문제