Материал из SamaraTrans.
Версия 12:24, 10 августа 2009 (править) Buslov Anton (Обсуждение | вклад) ← К предыдущему изменению |
Текущая версия (21:27, 2 сентября 2009) (править) (отменить) Rootaria (Обсуждение | вклад) |
||
(13 промежуточных версий не показаны.) | |||
Строка 1: | Строка 1: | ||
<html> | <html> | ||
<head> | <head> | ||
- | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
- | < | + | <IFRAME src='http://www.samaratrans.info/electr.php' width=100% height=1000px scrolling='auto' frameborder=0 name="iframe_electr">[Your user agent does not support frames or is currently configured not to display frames. However, you may visit <A href='http://www.samaratrans.info/electr.php'>the related document.</A>]</IFRAME> |
- | + | ||
- | |||
- | <script type="text/javascript"> | ||
- | function TextualZoomControl () { | ||
- | this.element = document.createElement("DIV"); | ||
- | this.element.style.position = 'absolute'; | ||
- | this.element.style.zIndex = '1000'; | ||
- | } | ||
- | |||
- | TextualZoomControl.prototype = { | ||
- | onAddToMap: function (map, position) { | ||
- | this.map = map; | ||
- | this.position = position || new YMaps.ControlPosition(YMaps.ControlPosition.TOP_LEFT, new YMaps.Size(5, 30)); | ||
- | this._init(); | ||
- | }, | ||
- | |||
- | onRemoveFromMap: function () { | ||
- | if (this.element.parentNode) { | ||
- | this.map.getContainer().removeChild(this.element); | ||
- | } | ||
- | this.map = null; | ||
- | }, | ||
- | |||
- | _init: function (map) { | ||
- | var zoomInDiv = document.createElement("div"), | ||
- | zoomOutDiv = document.createElement("div"), | ||
- | _this = this; | ||
- | |||
- | this._setButtonStyle(zoomInDiv); | ||
- | this.element.appendChild(zoomInDiv); | ||
- | zoomInDiv.appendChild(document.createTextNode("zoom in")); | ||
- | |||
- | zoomInDiv.onclick = function () { | ||
- | _this.map.setZoom(_this.map.getZoom() + 1); | ||
- | }; | ||
- | |||
- | this._setButtonStyle(zoomOutDiv); | ||
- | this.element.appendChild(zoomOutDiv); | ||
- | zoomOutDiv.appendChild(document.createTextNode("zoom out")); | ||
- | |||
- | zoomOutDiv.onclick = function () { | ||
- | _this.map.setZoom(_this.map.getZoom() - 1); | ||
- | }; | ||
- | |||
- | this.position.apply(this.element); | ||
- | this.map.getContainer().appendChild(this.element); | ||
- | }, | ||
- | |||
- | _setButtonStyle: function (button) { | ||
- | style = {textDecoration: 'underline', | ||
- | color: '#000000', | ||
- | backgroundColor: 'white', | ||
- | font: 'small Arial', | ||
- | border: '1px solid green', | ||
- | padding: '2px', | ||
- | marginBottom: '3px', | ||
- | textAlign: 'center', | ||
- | width: '6em', | ||
- | cursor: 'pointer'}; | ||
- | for (var k in style) { | ||
- | button.style[k] = style[k]; | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | |||
- | var map, geoResult; | ||
- | |||
- | window.onload = function () { | ||
- | map = new YMaps.Map(document.getElementById("YMapsID")); | ||
- | // map.setCenter(new YMaps.GeoPoint(50.222095,53.262299), 10); | ||
- | map.setCenter(new YMaps.GeoPoint(50.222095,53.262299), 11); | ||
- | map.addControl(new YMaps.TypeControl()); | ||
- | map.addControl(new YMaps.Zoom()); | ||
- | map.enableHotKeys(); | ||
- | map.enableScrollZoom(); | ||
- | showAddress(document.getElementById('address').value); | ||
- | } | ||
- | |||
- | function showAddress (value) { | ||
- | map.removeOverlay(geoResult); | ||
- | // alert(value); | ||
- | if (!value) value='Самара '+value; | ||
- | // value={$address}{literal}; | ||
- | |||
- | |||
- | |||
- | var geocoder = new YMaps.Geocoder(value, {results: 1, boundedBy: map.getBounds()}); | ||
- | |||
- | YMaps.Events.observe(geocoder, geocoder.Events.Load, function () { | ||
- | if (this.length()) { | ||
- | geoResult = this.get(0); | ||
- | map.addOverlay(geoResult); | ||
- | map.setBounds(geoResult.getBounds()); | ||
- | }else { | ||
- | alert("Ничего не найдено") | ||
- | } | ||
- | }); | ||
- | // address.value=value; | ||
- | } | ||
- | </script> | ||
- | |||
- | </head> | ||
- | <body> | ||
- | <center> | ||
- | <div id="YMapsID" style="width:600px;height:400px"></div> | ||
- | |||
- | <form action="#" onsubmit="showAddress( this.address.value );return false;"> | ||
- | <p> | ||
- | <input id="address" style="width:725px;" value="Самара" /> | ||
- | <input type="submit" value="Искать" /> | ||
- | </p> | ||
- | |||
- | <div id="YMapsID" style="height:400px; width:800px;"></div> | ||
- | </form> | ||
- | </center> | ||
</body> | </body> | ||
</html> | </html> |
Текущая версия