Клуб API Карт

Помогите разобраться с картой!как перевести в народную карту

Пост в архиве.

Ребят помогите разобраться с картами, мне нужно из обычной карты сделать народную

4 комментария

в этом коде не могу найти где можно было изменить на народную

 

class Service_Map_YandexMaps extends Service_Map_Maps {

 

private function getInitScript($containerDOMName, $setCenter = true) {

 

$script = 

'map = new YMaps.Map(document.getElementById("'.$containerDOMName.'"));

map.addControl(new YMaps.Zoom());

map.addControl(new YMaps.ScaleLine());

map.addControl(new YMaps.MiniMap());

map.addControl(new YMaps.ToolBar());

map.addControl(new YMaps.TypeControl());

map.setMinZoom(12);

'; 

if ($this->traffic) {

$script .=

'YMaps.load("traffic", function() {map.addControl(new YMaps.Traffic.Control());});

';

}

if ($setCenter) {

$script .=

'map.setCenter(new YMaps.GeoPoint('.$this->mapCoords['centerLng'].', '.$this->mapCoords['centerLat'].'), '.$this->mapCoords['initZoom'].');

';

}

 

return $script;

}

 

private function getShowAddressScript() {

$script = 

'function showAddress (value) {

var bounds = new YMaps.GeoBounds(

new YMaps.GeoPoint('.$this->mapCoords['searchRectLeftBottomLng'].', '.$this->mapCoords['searchRectLeftBottomLat'].'),

new YMaps.GeoPoint('.$this->mapCoords['searchRectRightTopLng'].', '.$this->mapCoords['searchRectRightTopLat'].'));

var geocoder = new YMaps.Geocoder(value, {boundedBy: bounds, strictBounds: true, '.($this->lang?'prefLang: "'.$this->lang.'"':'').'});

YMaps.Events.observe(geocoder, geocoder.Events.Load, function () {

if (this.length()) {

for (var i = this.length() - 1; i >= 0; i--) {

map.addOverlay(this.get(i));

if (i == 0) {

map.panTo(this.get(i).getGeoPoint());

this.get(i).setBalloonContent(this.get(i).text);

this.get(i).openBalloon();

}

}

} else {

alert("Ничего не найдено");

}

});

YMaps.Events.observe(geocoder, geocoder.Events.Fault, function (error) { alert("Произошла ошибка: " + error.message); });

}

';

return $script;

}

 

public function __construct($map_config) {

 

parent::__construct($map_config);

$this->nameService = 'Yandex Maps';

$this->APIScriptLocation = 'http://api-maps.yandex.ru/1.1/index.xml?key='.$this->keyAPI;

$this->traffic = $map_config->traffic;

$this->lang = $map_config->lang;

}

 

public function getDefaultMapPageScript($containerDOMName, $searchInputDOMName) {

$script =

'var map;

window.onload = function () {

'

.$this->getInitScript($containerDOMName).

 

'}

 

window.onunload = function() {

map.destructor();

}

 

'

.$this->getShowAddressScript().

 

'

function showAddressExample(value) {

$("#'.$searchInputDOMName.'").val(value);

map.removeAllOverlays();

showAddress(value);

}

 

function showSubcatMarkers(subcat_id, subcat_name) {

if (map) {

$.post("/map/showcatalogonmap", {subcat:subcat_id}, function(data) {

$("span#kroshkiSubcatName").html(" / "+subcat_name);

$("span#h1Subcatname").html(" / "+subcat_name);

ShowMarkers(data);

}, "json");

}

}

 

function showCatMarkers(cat_id, cat_name) {

if (map) {

$.post("/map/showcatalogonmap", {cat:cat_id}, function(data) {

$("span#kroshkiSubcatName").html(" / "+cat_name);

$("span#h1Subcatname").html(" / "+cat_name);

ShowMarkers(data);

}, "json");

}

}

 

function ShowMarkers(data) {

map.removeAllOverlays();

for (var i = 0; i < data.length; i++) {

var s = new YMaps.Style();

s.iconStyle = new YMaps.IconStyle();

s.iconStyle.href = data[i].map_icon;

s.iconStyle.size = new YMaps.Point(22, 30);

s.iconStyle.offset = new YMaps.Point(-5, -30);

var placemark = new YMaps.Placemark(new YMaps.GeoPoint(data[i].geo_coord_lng, data[i].geo_coord_lat), {style: s});

baloonHtml = "

data[i].logo +

"\" width=\"50px\" border=\"0\" />

data[i].id +

"\">" +

data[i].firmname +

"


" +

data[i].adress +

"";

placemark.setBalloonContent(baloonHtml);

map.addOverlay(placemark);

}

}';

return $script;

}

 

public function getShowonmapPageScript($containerDOMName, $addresses) {

 

$script =

'var map, markers;

window.onload = function () {

 

var wH = document.documentElement.clientHeight - 20;

document.getElementById("'.$containerDOMName.'").style.height = wH+"px";

';

//Zend_Debug::dump($addresses);

$script .=

'markers = [';

$i = array();

foreach ($addresses as $address) {

$i[] = '

["'.$address['geo_coord_lng'].'","'.$address['geo_coord_lat'].'","'.addslashes($address['marker_name']).'","'. addslashes($address['address']).'"]';

}

 

$script .= implode(',', $i);

$script .= '

];';

 

$script .= '

'

.$this->getInitScript($containerDOMName, false);

 

foreach ($addresses as $address) {

if (!empty($address['geo_coord_lng']) && !empty($address['geo_coord_lat'])) {

$script .= '

var placemark = new YMaps.Placemark(new YMaps.GeoPoint('.$address['geo_coord_lng'].','.$address['geo_coord_lat'].'), {

draggable: false,

hasBalloon: false

});

placemark.setIconContent("'.$address['marker_name'].'");

map.addOverlay(placemark);';

 

}

}

 

if (!empty($addresses[0]['geo_coord_lng']) && !empty($addresses[0]['geo_coord_lat'])) {

$script .=

'

 

map.setCenter(new YMaps.GeoPoint('.$addresses[0]['geo_coord_lng'].', '.$addresses[0]['geo_coord_lat'].'), 16);

';

} else {

$script .=

'placeOnCenter(markers[0]);

';

}

 

$script .=

'}

 

window.onunload = function() {

map.destructor();

}

 

function placeOnCenter(marker) {

if ("" == marker[0] || "" == marker[1]) {

showAddress(marker[3]);

} else {

map.panTo(new YMaps.GeoPoint(marker[0], marker[1]));

}

}

 

';

 

$script .= $this->getShowAddressScript();

 

return $script;

}

 

public function getShowonmapAddressPageScript($containerDOMName, $address) {

 

$script =

'var map, geoResult;

window.onload = function () {

 

var wH = document.documentElement.clientHeight - 20;

document.getElementById("'.$containerDOMName.'").style.height = wH+"px";

'

.$this->getInitScript($containerDOMName).

 

'

showAddress("'.$address.'");

}

 

window.onunload = function() {

map.destructor();

}

 

'.$this->getShowAddressScript();

 

return $script;

}

 

public function getAdminListPageScript($containerDOMName, $markers) {

 

$script =

'var map;

window.onload = function () {

'

.$this->getInitScript($containerDOMName).

'

';

 

foreach ($markers as $_marker) {

if (!empty($_marker['geo_coord_lat']) && !(empty($_marker['geo_coord_lng']))) {

$script .=

'placemark = new YMaps.Placemark(new YMaps.GeoPoint('.$_marker['geo_coord_lng'].','.$_marker['geo_coord_lat'].'), {

draggable: false,

hasBalloon: false

});

placemark.setIconContent("'.$_marker['marker_name'].'");

map.addOverlay(placemark);

';

}

}

 

$script .=

'};

 

window.onunload = function() {

map.destructor();

};

 

'.$this->getShowAddressScript();

return $script;

}

 

public function getAdminEditPageScript($containerDOMName, $marker) {

 

$script =

'var map;

window.onload = function () {

map = new YMaps.Map(document.getElementById("'.$containerDOMName.'"));

map.setMinZoom(12);

map.addControl(new YMaps.Zoom());

map.addControl(new YMaps.ScaleLine());

map.addControl(new YMaps.MiniMap());

map.addControl(new YMaps.ToolBar());

map.setCenter(new YMaps.GeoPoint('.$this->mapCoords['centerLng'].', '.$this->mapCoords['centerLat'].'), 12);

 

var placemark = new YMaps.Placemark(new YMaps.GeoPoint('.$marker['geo_coord_lng'].','.$marker['geo_coord_lat'].'), {

draggable: true,

hasBalloon: false

});

placemark.setIconContent("'.$marker['marker_name'].'");

map.addOverlay(placemark);

 

YMaps.Events.observe(placemark, placemark.Events.DragEnd, function (mEvent) {

document.getElementById("geo_coord_lat").value = mEvent.getGeoPoint().getLat();

document.getElementById("geo_coord_lng").value = mEvent.getGeoPoint().getLng();

});

}

 

window.onunload = function() {

map.destructor();

}

 

'.$this->getShowAddressScript();

return $script;

}

 

}

Вы используете первую версию апи. Тогда вам надо почитать вот эту статью http://api.yandex.ru/maps/doc/jsapi/1.x/mod/concepts/pmap.xml. Там написано, как подключить модуль народной карты.

а куда это все прописывать не подскажите?