Здравствуйте!
Мне нужно поставить второй маркер на карте Гугл. Бьюсь 2 часа не получается. http://mirta2.monreall.net/content/gde-kupit
Вот код.
<div id="map1">
</div>
<!-- CONTACT CONTAINER -->
<div class="container" style="background:url(<?php echo $root; ?>/img/stripes.png);">
<section class="row white">
</div>
</div>
</section>
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true">
</script>
<script src="<?php echo $root;?>/js/maps1.js">
</script>
<script type="text/javascript">
//<![CDATA[
var map;
jQuery(document).ready(function ($) {
prettyPrint();
map = new GMaps({
div: '#map1',
lat: 52.71964,
lng: 41.437933,
});
map.addMarker({
lat: 52.71964,
lng: 41.437933,
title: 'Фабрика «Мирта», г. Саранск, ул. Северная, 19а',
click: function(e){
if(console.log)
console.log(e);
alert('You clicked in this marker');
}
});
});
//]]>
</script>
Комментарии
Бред пьяного кодера!
вот какраз для таких как вы и делалось https://drupal.org/project/mappy
Почему? Я программировать не умею. Я дал код с одним маркером. Код писал не я... он взят из шаблона... нужно еще один маркер поставить... дайте мне пример... я координаты свои поставлю... помогите! вы же тоже не всегда такими продвинутыми веб-мастерами были))) с чего начинали...
Я дал модуль, который сделал специально для случаев
http://niklan.net/blog/42 - если лень гуглить
В IE карта с вашего модуля не отображается. Придется выводить все через прежний скрипт. Вопрос остается открытым. Как добавить второй маркер?
версия IE
по вашему скрипту. ХЗ что за версия карт используется, что вообще за говнокод используется. Ничего не ясно. Поменял на догадках. Ваша задача проверить и подставить во вторую марку свои Lat и Long
jQuery(document).ready(function ($) {
prettyPrint();
map = new GMaps({
div: '#map1',
lat: 52.71964,
lng: 41.437933,
});
// Метка 1
var marker = new google.maps.Marker({
position: new google.maps.LatLng(52.71964, 41.437933),
map: map,
title: 'Фабрика «Мирта», г. Саранск, ул. Северная, 19а'
});
// Метка 2
var marker = new google.maps.Marker({
position: new google.maps.LatLng(52.71964, 41.437933),
map: map,
title: 'Фабрика «Мирта», г. Саранск, ул. Северная, 19а'
});
});
Можете в моём коде (из модуля) посмотреть как я с гугл картами работаю. Добавление меток прям копипастом оттуда https://github.com/Niklan/mappy/blob/7.x-1.x/js/google.mappy.js
Нет, не прошло... у меня отобразилась пустая карта без маркеров. Даю текст скрипта maps1.js
<?php/*!
* GMaps.js v0.2.14
* http://hpneo.github.com/gmaps/
*
* Copyright 2012, Gustavo Leon
* Released under the MIT License.
*/
if(window.google && window.google.maps){
var GMaps = (function(global) {
"use strict";
var doc = document;
var getElementById = function(id, context) {
var ele
if('jQuery' in global && context){
ele = $("#"+id.replace('#', ''), context)[0]
}else{
ele = doc.getElementById(id.replace('#', ''));
};
return ele;
};
var GMaps = function(options) {
var self = this;
window.context_menu = {};
if(typeof(options.div)=='string'){
this.div = getElementById(options.div, options.context);
}else{this.div = options.div;};
this.div.style.width = options.width || this.div.scrollWidth || this.div.offsetWidth;
this.div.style.height = options.height || this.div.scrollHeight || this.div.offsetHeight;
this.controls = [];
this.overlays = [];
this.layers = []; // array with kml and ft layers, can be as many
this.singleLayers = {}; // object with the other layers, only one per layer
this.markers = [];
this.polylines = [];
this.routes = [];
this.polygons = [];
this.infoWindow = null;
this.overlay_div = null;
this.zoom = options.zoom || 15;
//'Hybrid', 'Roadmap', 'Satellite' or 'Terrain'
var mapType;
if (options.mapType) {
mapType = google.maps.MapTypeId[options.mapType.toUpperCase()];
}
else {
mapType = google.maps.MapTypeId.ROADMAP;
}
var map_center = new google.maps.LatLng(options.lat, options.lng);
delete options.div;
delete options.lat;
delete options.lng;
delete options.mapType;
delete options.width;
delete options.height;
var zoomControlOpt = options.zoomControlOpt || {
style: 'DEFAULT',
position: 'TOP_LEFT'
};
var zoomControl = options.zoomControl || true,
zoomControlStyle = zoomControlOpt.style || 'DEFAULT',
zoomControlPosition = zoomControlOpt.position || 'TOP_LEFT',
panControl = options.panControl || true,
mapTypeControl = options.mapTypeControl || true,
scaleControl = options.scaleControl || true,
streetViewControl = options.streetViewControl || true,
overviewMapControl = overviewMapControl || true;
var map_base_options = {
zoom: this.zoom,
center: map_center,
mapTypeId: mapType,
panControl: panControl,
zoomControl: zoomControl,
zoomControlOptions: {
style: google.maps.ZoomControlStyle[zoomControlStyle], // DEFAULT LARGE SMALL
position: google.maps.ControlPosition[zoomControlPosition]
},
mapTypeControl: mapTypeControl,
scaleControl: scaleControl,
streetViewControl: streetViewControl,
overviewMapControl: overviewMapControl
};
var map_options = extend_object(map_base_options, options);
this.map = new google.maps.Map(this.div, map_options);
// Context menus
var buildContextMenuHTML = function(control, e) {
var html = '';
var options = window.context_menu[control];
for (var i in options){
if (options.hasOwnProperty(i)){
var option = options[i];
html += '<li><a id="' + control + '_' + i + '" href="#">' +
option.title + '</a></li>';
}
}
if(!getElementById('gmaps_context_menu')) return;
var context_menu_element = getElementById('gmaps_context_menu');
context_menu_element.innerHTML = html;
var context_menu_items = context_menu_element.getElementsByTagName('a');
var context_menu_items_count = context_menu_items.length;
for(var i=0;i<context_menu_items_count;i++){
var context_menu_item = context_menu_items[i];
var assign_menu_item_action = function(ev){
ev.preventDefault();
options[this.id.replace(control + '_', '')].action.call(self, e);
self.hideContextMenu();
};
google.maps.event.clearListeners(context_menu_item, 'click');
google.maps.event.addDomListenerOnce(context_menu_item, 'click', assign_menu_item_action, false);
}
var left = self.div.offsetLeft + e.pixel.x - 15;
var top = self.div.offsetTop + e.pixel.y - 15;
context_menu_element.style.left = left + "px";
context_menu_element.style.top = top + "px";
context_menu_element.style.display = 'block';
};
var buildContextMenu = function(control, e) {
if (control === 'marker') {
e.pixel = {};
var overlay = new google.maps.OverlayView();
overlay.setMap(self.map);
overlay.draw = function() {
var projection = overlay.getProjection();
var position = e.marker.getPosition();
e.pixel = projection.fromLatLngToContainerPixel(position);
buildContextMenuHTML(control, e);
};
}
else {
buildContextMenuHTML(control, e);
}
};
this.setContextMenu = function(options) {
window.context_menu[options.control] = {};
for (var i in options.options){
if (options.options.hasOwnProperty(i)){
var option = options.options[i];
window.context_menu[options.control][option.name] = {
title: option.title,
action: option.action
};
}
}
var ul = doc.createElement('ul');
ul.id = 'gmaps_context_menu';
ul.style.display = 'none';
ul.style.position = 'absolute';
ul.style.minWidth = '100px';
ul.style.background = 'white';
ul.style.listStyle = 'none';
ul.style.padding = '8px';
ul.style.boxShadow = '2px 2px 6px #ccc';
doc.body.appendChild(ul);
var context_menu_element = getElementById('gmaps_context_menu');
google.maps.event.addDomListener(context_menu_element, 'mouseout', function(ev) {
if(!ev.relatedTarget || !this.contains(ev.relatedTarget)){
window.setTimeout(function(){
context_menu_element.style.display = 'none';
}, 400);
}
}, false);
};
this.hideContextMenu = function() {
var context_menu_element = getElementById('gmaps_context_menu');
if(context_menu_element)
context_menu_element.style.display = 'none';
};
//Events
var events_that_hide_context_menu = ['bounds_changed', 'center_changed', 'click', 'dblclick', 'drag', 'dragend', 'dragstart', 'idle', 'maptypeid_changed', 'projection_changed', 'resize', 'tilesloaded', 'zoom_changed'];
var events_that_doesnt_hide_context_menu = ['mousemove', 'mouseout', 'mouseover'];
for (var ev = 0; ev < events_that_hide_context_menu.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if(e == undefined)
e = this;
if (options[name])
options[name].apply(this, [e]);
self.hideContextMenu();
});
})(this.map, events_that_hide_context_menu[ev]);
}
for (var ev = 0; ev < events_that_doesnt_hide_context_menu.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if(e == undefined)
e = this;
if (options[name])
options[name].apply(this, [e]);
});
})(this.map, events_that_doesnt_hide_context_menu[ev]);
}
google.maps.event.addListener(this.map, 'rightclick', function(e) {
if (options.rightclick) {
options.rightclick.apply(this, [e]);
}
buildContextMenu('map', e);
});
this.refresh = function() {
google.maps.event.trigger(this.map, 'resize');
};
this.fitZoom = function() {
var latLngs = [];
var markers_length = this.markers.length;
for(var i=0; i < markers_length; i++) {
latLngs.push(this.markers[i].getPosition());
}
this.fitBounds(latLngs);
};
this.fitBounds = function(latLngs) {
var total = latLngs.length;
var bounds = new google.maps.LatLngBounds();
for(var i=0; i < total; i++) {
bounds.extend(latLngs[i]);
}
this.map.fitBounds(bounds);
};
// Map methods
this.setCenter = function(lat, lng, callback) {
this.map.panTo(new google.maps.LatLng(lat, lng));
if (callback) {
callback();
}
};
this.getDiv = function() {
return this.div;
};
this.zoomIn = function(value) {
this.zoom = this.map.getZoom() + value;
this.map.setZoom(this.zoom);
};
this.zoomOut = function(value) {
this.zoom = this.map.getZoom() - value;
this.map.setZoom(this.zoom);
};
var native_methods = [];
for(var method in this.map){
if(typeof(this.map[method]) == 'function' && !this[method]){
native_methods.push(method);
}
}
for(var i=0; i < native_methods.length; i++){
(function(gmaps, scope, method_name) {
gmaps[method_name] = function(){
return scope[method_name].apply(scope, arguments);
};
})(this, this.map, native_methods[i]);
}
this.createControl = function(options) {
var control = doc.createElement('div');
control.style.cursor = 'pointer';
control.style.fontFamily = 'Arial, sans-serif';
control.style.fontSize = '13px';
control.style.boxShadow = 'rgba(0, 0, 0, 0.398438) 0px 2px 4px';
for(var option in options.style)
control.style[option] = options.style[option];
if(options.id) {
control.id = options.id;
}
if(options.classes) {
control.className = options.classes;
}
if(options.content) {
control.innerHTML = options.content;
}
for (var ev in options.events) {
(function(object, name) {
google.maps.event.addDomListener(object, name, function(){
options.events[name].apply(this, [this]);
});
})(control, ev);
}
control.index = 1;
return control;
};
this.addControl = function(options) {
var position = google.maps.ControlPosition[options.position.toUpperCase()];
delete options.position;
var control = this.createControl(options);
this.controls.push(control);
this.map.controls[position].push(control);
return control;
};
// Markers
this.createMarker = function(options) {
if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
var self = this;
var details = options.details;
var fences = options.fences;
var outside = options.outside;
var base_options = {
position: new google.maps.LatLng(options.lat, options.lng),
map: null
};
delete options.lat;
delete options.lng;
delete options.fences;
delete options.outside;
var marker_options = extend_object(base_options, options);
var marker = new google.maps.Marker(marker_options);
marker.fences = fences;
if (options.infoWindow) {
marker.infoWindow = new google.maps.InfoWindow(options.infoWindow);
var info_window_events = ['closeclick', 'content_changed', 'domready', 'position_changed', 'zindex_changed'];
for (var ev = 0; ev < info_window_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options.infoWindow[name])
options.infoWindow[name].apply(this, [e]);
});
})(marker.infoWindow, info_window_events[ev]);
}
}
var marker_events = ['animation_changed', 'clickable_changed', 'cursor_changed', 'draggable_changed', 'flat_changed', 'icon_changed', 'position_changed', 'shadow_changed', 'shape_changed', 'title_changed', 'visible_changed', 'zindex_changed'];
var marker_events_with_mouse = ['dblclick', 'drag', 'dragend', 'dragstart', 'mousedown', 'mouseout', 'mouseover', 'mouseup'];
for (var ev = 0; ev < marker_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(){
if (options[name])
options[name].apply(this, [this]);
});
})(marker, marker_events[ev]);
}
for (var ev = 0; ev < marker_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(me){
if(!me.pixel){
me.pixel = this.map.getProjection().fromLatLngToPoint(me.latLng)
}
if (options[name])
options[name].apply(this, [me]);
});
})(marker, marker_events_with_mouse[ev]);
}
google.maps.event.addListener(marker, 'click', function() {
this.details = details;
if (options.click) {
options.click.apply(this, [this]);
}
if (marker.infoWindow) {
self.hideInfoWindows();
marker.infoWindow.open(self.map, marker);
}
});
if (options.dragend || marker.fences) {
google.maps.event.addListener(marker, 'dragend', function() {
if (marker.fences) {
self.checkMarkerGeofence(marker, function(m, f) {
outside(m, f);
});
}
});
}
return marker;
}
else {
throw 'No latitude or longitude defined';
}
};
this.addMarker = function(options) {
if ((options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) || options.position) {
var marker = this.createMarker(options);
marker.setMap(this.map);
this.markers.push(marker);
return marker;
}
else {
throw 'No latitude or longitude defined';
}
};
this.addMarkers = function(array) {
for (var i=0, marker; marker=array[i]; i++) {
this.addMarker(marker);
}
return this.markers;
};
this.hideInfoWindows = function() {
for (var i=0, marker; marker=this.markers[i]; i++){
if (marker.infoWindow){
marker.infoWindow.close();
}
}
};
this.removeMarkers = function(collection) {
var collection = (collection || this.markers);
for(var i=0;i < this.markers.length; i++){
if(this.markers[i] === collection[i])
this.markers[i].setMap(null);
}
var new_markers = [];
for(var i=0;i < this.markers.length; i++){
if(this.markers[i].getMap() != null)
new_markers.push(this.markers[i]);
}
this.markers = new_markers;
};
// Overlays
this.drawOverlay = function(options) {
var overlay = new google.maps.OverlayView();
overlay.setMap(self.map);
var auto_show = true;
if(options.auto_show != null)
auto_show = options.auto_show;
overlay.onAdd = function() {
var div = doc.createElement('div');
div.style.borderStyle = "none";
div.style.borderWidth = "0px";
div.style.position = "absolute";
div.style.zIndex = 100;
div.innerHTML = options.content;
overlay.div = div;
var panes = this.getPanes();
if (!options.layer) {
options.layer = 'overlayLayer';
}
var overlayLayer = panes[options.layer];
overlayLayer.appendChild(div);
var stop_overlay_events = ['contextmenu', 'DOMMouseScroll', 'dblclick', 'mousedown'];
for (var ev = 0; ev < stop_overlay_events.length; ev++) {
(function(object, name) {
google.maps.event.addDomListener(object, name, function(e){
if(navigator.userAgent.toLowerCase().indexOf('msie') != -1 && document.all) {
e.cancelBubble = true;
e.returnValue = false;
}
else {
e.stopPropagation();
}
});
})(div, stop_overlay_events[ev]);
}
google.maps.event.trigger(this, 'ready');
};
overlay.draw = function() {
var projection = this.getProjection();
var pixel = projection.fromLatLngToDivPixel(new google.maps.LatLng(options.lat, options.lng));
options.horizontalOffset = options.horizontalOffset || 0;
options.verticalOffset = options.verticalOffset || 0;
var div = overlay.div;
var content = div.children[0];
var content_height = content.clientHeight;
var content_width = content.clientWidth;
switch (options.verticalAlign) {
case 'top':
div.style.top = (pixel.y - content_height + options.verticalOffset) + 'px';
break;
default:
case 'middle':
div.style.top = (pixel.y - (content_height / 2) + options.verticalOffset) + 'px';
break;
case 'bottom':
div.style.top = (pixel.y + options.verticalOffset) + 'px';
break;
}
switch (options.horizontalAlign) {
case 'left':
div.style.left = (pixel.x - content_width + options.horizontalOffset) + 'px';
break;
default:
case 'center':
div.style.left = (pixel.x - (content_width / 2) + options.horizontalOffset) + 'px';
break;
case 'right':
div.style.left = (pixel.x + options.horizontalOffset) + 'px';
break;
}
div.style.display = auto_show ? 'block' : 'none';
if(!auto_show){
options.show.apply(this, [div]);
}
};
overlay.onRemove = function() {
var div = overlay.div;
if(options.remove){
options.remove.apply(this, [div]);
}
else{
overlay.div.parentNode.removeChild(overlay.div);
overlay.div = null;
}
};
self.overlays.push(overlay);
return overlay;
};
this.removeOverlay = function(overlay) {
overlay.setMap(null);
};
this.removeOverlays = function() {
for (var i=0, item; item=self.overlays[i]; i++){
item.setMap(null);
}
self.overlays = [];
};
this.removePolylines = function() {
for (var i=0, item; item=self.polylines[i]; i++){
item.setMap(null);
}
self.polylines = [];
};
this.drawPolyline = function(options) {
var path = [];
var points = options.path;
if (points.length){
if (points[0][0] === undefined){
path = points;
}
else {
for (var i=0, latlng; latlng=points[i]; i++){
path.push(new google.maps.LatLng(latlng[0], latlng[1]));
}
}
}
var polyline = new google.maps.Polyline({
map: this.map,
path: path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight,
geodesic: options.geodesic
});
var polyline_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polyline_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polyline, polyline_events[ev]);
}
this.polylines.push(polyline);
return polyline;
};
this.drawCircle = function(options) {
options = extend_object({
map: this.map,
center: new google.maps.LatLng(options.lat, options.lng)
}, options);
delete options.lat;
delete options.lng;
var polygon = new google.maps.Circle(options);
var polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polygon_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polygon, polygon_events[ev]);
}
this.polygons.push(polygon);
return polygon;
};
this.drawRectangle = function(options) {
options = extend_object({
map: this.map
}, options);
var latLngBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(options.bounds[0][0], options.bounds[0][1]),
new google.maps.LatLng(options.bounds[1][0], options.bounds[1][1])
);
options.bounds = latLngBounds;
var polygon = new google.maps.Rectangle(options);
var polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polygon_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polygon, polygon_events[ev]);
}
this.polygons.push(polygon);
return polygon;
};
this.drawPolygon = function(options) {
options = extend_object({
map: this.map
}, options);
if(options.paths.length > 0) {
if(options.paths[0].length > 0) {
options.paths = array_map(options.paths, arrayToLatLng);
}
}
var polygon = new google.maps.Polygon(options);
var polygon_events = ['click', 'dblclick', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'rightclick'];
for (var ev = 0; ev < polygon_events.length; ev++) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
if (options[name])
options[name].apply(this, [e]);
});
})(polygon, polygon_events[ev]);
}
this.polygons.push(polygon);
return polygon;
};
this.removePolygon = this.removeOverlay;
this.removePolygons = function() {
for (var i=0, item; item=self.polygons[i]; i++){
item.setMap(null);
}
self.polygons = [];
};
this.getFromFusionTables = function(options) {
var events = options.events;
delete options.events;
var fusion_tables_options = options;
var layer = new google.maps.FusionTablesLayer(fusion_tables_options);
for (var ev in events) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
events[name].apply(this, [e]);
});
})(layer, ev);
}
this.layers.push(layer);
return layer;
};
this.loadFromFusionTables = function(options) {
var layer = this.getFromFusionTables(options);
layer.setMap(this.map);
return layer;
};
this.getFromKML = function(options) {
var url = options.url;
var events = options.events;
delete options.url;
delete options.events;
var kml_options = options;
var layer = new google.maps.KmlLayer(url, kml_options);
for (var ev in events) {
(function(object, name) {
google.maps.event.addListener(object, name, function(e){
events[name].apply(this, [e]);
});
})(layer, ev);
}
this.layers.push(layer);
return layer;
};
this.loadFromKML = function(options) {
var layer = this.getFromKML(options);
layer.setMap(this.map);
return layer;
};
// Services
var travelMode, unitSystem;
this.getRoutes = function(options) {
switch (options.travelMode) {
case 'bicycling':
travelMode = google.maps.TravelMode.BICYCLING;
break;
case 'transit':
travelMode = google.maps.TravelMode.TRANSIT;
break;
case 'driving':
travelMode = google.maps.TravelMode.DRIVING;
break;
// case 'walking':
default:
travelMode = google.maps.TravelMode.WALKING;
break;
}
if (options.unitSystem === 'imperial') {
unitSystem = google.maps.UnitSystem.IMPERIAL;
}
else {
unitSystem = google.maps.UnitSystem.METRIC;
}
var base_options = {
avoidHighways: false,
avoidTolls: false,
optimizeWaypoints: false,
waypoints: []
};
var request_options = extend_object(base_options, options);
request_options.origin = new google.maps.LatLng(options.origin[0], options.origin[1]);
request_options.destination = new google.maps.LatLng(options.destination[0], options.destination[1]);
request_options.travelMode = travelMode;
request_options.unitSystem = unitSystem;
delete request_options.callback;
var self = this;
var service = new google.maps.DirectionsService();
service.route(request_options, function(result, status) {
if (status === google.maps.DirectionsStatus.OK) {
for (var r in result.routes) {
if (result.routes.hasOwnProperty(r)) {
self.routes.push(result.routes[r]);
}
}
}
if (options.callback) {
options.callback(self.routes);
}
});
};
this.removeRoutes = function() {
this.routes = [];
};
this.getElevations = function(options) {
options = extend_object({
locations: [],
path : false,
samples : 256
}, options);
if(options.locations.length > 0) {
if(options.locations[0].length > 0) {
options.locations = array_map(options.locations, arrayToLatLng);
}
}
var callback = options.callback;
delete options.callback;
var service = new google.maps.ElevationService();
//location request
if (!options.path) {
delete options.path;
delete options.samples;
service.getElevationForLocations(options, function(result, status){
if (callback && typeof(callback) === "function") {
callback(result, status);
}
});
//path request
} else {
var pathRequest = {
path : options.locations,
samples : options.samples
};
service.getElevationAlongPath(pathRequest, function(result, status){
if (callback && typeof(callback) === "function") {
callback(result, status);
}
});
}
};
// Alias for the method "drawRoute"
this.cleanRoute = this.removePolylines;
this.drawRoute = function(options) {
var self = this;
this.getRoutes({
origin: options.origin,
destination: options.destination,
travelMode: options.travelMode,
waypoints : options.waypoints,
callback: function(e) {
if (e.length > 0) {
self.drawPolyline({
path: e[e.length - 1].overview_path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
if (options.callback) {
options.callback(e[e.length - 1]);
}
}
}
});
};
this.travelRoute = function(options) {
if (options.origin && options.destination) {
this.getRoutes({
origin: options.origin,
destination: options.destination,
travelMode: options.travelMode,
waypoints : options.waypoints,
callback: function(e) {
//start callback
if (e.length > 0 && options.start) {
options.start(e[e.length - 1]);
}
//step callback
if (e.length > 0 && options.step) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
options.step(step, (route.legs[0].steps.length - 1));
}
}
}
//end callback
if (e.length > 0 && options.end) {
options.end(e[e.length - 1]);
}
}
});
}
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
options.step(step);
}
}
}
};
this.drawSteppedRoute = function(options) {
if (options.origin && options.destination) {
this.getRoutes({
origin: options.origin,
destination: options.destination,
travelMode: options.travelMode,
waypoints : options.waypoints,
callback: function(e) {
//start callback
if (e.length > 0 && options.start) {
options.start(e[e.length - 1]);
}
//step callback
if (e.length > 0 && options.step) {
var route = e[e.length - 1];
if (route.legs.length > 0) {
var steps = route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
options.step(step, (route.legs[0].steps.length - 1));
}
}
}
//end callback
if (e.length > 0 && options.end) {
options.end(e[e.length - 1]);
}
}
});
}
else if (options.route) {
if (options.route.legs.length > 0) {
var steps = options.route.legs[0].steps;
for (var i=0, step; step=steps[i]; i++) {
step.step_number = i;
self.drawPolyline({
path: step.path,
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
});
options.step(step);
}
}
}
};
// Geofence
this.checkGeofence = function(lat, lng, fence) {
return fence.containsLatLng(new google.maps.LatLng(lat, lng));
};
this.checkMarkerGeofence = function(marker, outside_callback) {
if (marker.fences) {
for (var i=0, fence; fence=marker.fences[i]; i++) {
var pos = marker.getPosition();
if (!self.checkGeofence(pos.lat(), pos.lng(), fence)) {
outside_callback(marker, fence);
}
}
}
};
//add layers to the maps
this.addLayer = function(layerName, options) {
//var default_layers = ['weather', 'clouds', 'traffic', 'transit', 'bicycling', 'panoramio', 'places'];
options = options || {};
var layer;
switch(layerName) {
case 'weather': this.singleLayers.weather = layer = new google.maps.weather.WeatherLayer();
break;
case 'clouds': this.singleLayers.clouds = layer = new google.maps.weather.CloudLayer();
break;
case 'traffic': this.singleLayers.traffic = layer = new google.maps.TrafficLayer();
break;
case 'transit': this.singleLayers.transit = layer = new google.maps.TransitLayer();
break;
case 'bicycling': this.singleLayers.bicycling = layer = new google.maps.BicyclingLayer();
break;
case 'panoramio':
this.singleLayers.panoramio = layer = new google.maps.panoramio.PanoramioLayer();
layer.setTag(options.filter);
delete options.filter;
//click event
if(options.click) {
google.maps.event.addListener(layer, 'click', function(event) {
options.click(event);
delete options.click;
});
}
break;
case 'places':
this.singleLayers.places = layer = new google.maps.places.PlacesService(this.map);
//search and nearbySearch callback, Both are the same
if(options.search || options.nearbySearch) {
var placeSearchRequest = {
bounds : options.bounds || null,
keyword : options.keyword || null,
location : options.location || null,
name : options.name || null,
radius : options.radius || null,
rankBy : options.rankBy || null,
types : options.types || null
};
if(options.search) {
layer.search(placeSearchRequest, options.search);
}
if(options.nearbySearch) {
layer.nearbySearch(placeSearchRequest, options.nearbySearch);
}
}
//textSearch callback
if(options.textSearch) {
var textSearchRequest = {
bounds : options.bounds || null,
location : options.location || null,
query : options.query || null,
radius : options.radius || null
};
layer.textSearch(textSearchRequest, options.textSearch);
}
break;
}
if(layer !== undefined) {
if(typeof layer.setOptions == 'function') {
layer.setOptions(options);
}
if(typeof layer.setMap == 'function') {
layer.setMap(this.map);
}
return layer;
}
};
//remove layers
this.removeLayer = function(layerName) {
if(this.singleLayers[layerName] !== undefined) {
this.singleLayers[layerName].setMap(null);
delete this.singleLayers[layerName];
}
};
this.toImage = function(options) {
var options = options || {};
var static_map_options = {};
static_map_options['size'] = options['size'] || [this.div.clientWidth, this.div.clientHeight];
static_map_options['lat'] = this.getCenter().lat();
static_map_options['lng'] = this.getCenter().lng();
if(this.markers.length > 0) {
static_map_options['markers'] = [];
for(var i=0; i < this.markers.length; i++) {
static_map_options['markers'].push({
lat: this.markers[i].getPosition().lat(),
lng: this.markers[i].getPosition().lng()
});
}
}
if(this.polylines.length > 0) {
var polyline = this.polylines[0];
static_map_options['polyline'] = {};
static_map_options['polyline']['path'] = google.maps.geometry.encoding.encodePath(polyline.getPath());
static_map_options['polyline']['strokeColor'] = polyline.strokeColor
static_map_options['polyline']['strokeOpacity'] = polyline.strokeOpacity
static_map_options['polyline']['strokeWeight'] = polyline.strokeWeight
}
return GMaps.staticMapURL(static_map_options);
};
};
GMaps.Route = function(options) {
this.map = options.map;
this.route = options.route;
this.step_count = 0;
this.steps = this.route.legs[0].steps;
this.steps_length = this.steps.length;
this.polyline = this.map.drawPolyline({
path: new google.maps.MVCArray(),
strokeColor: options.strokeColor,
strokeOpacity: options.strokeOpacity,
strokeWeight: options.strokeWeight
}).getPath();
this.back = function() {
if (this.step_count > 0) {
this.step_count--;
var path = this.route.legs[0].steps[this.step_count].path;
for (var p in path){
if (path.hasOwnProperty(p)){
this.polyline.pop();
}
}
}
};
this.forward = function() {
if (this.step_count < this.steps_length) {
var path = this.route.legs[0].steps[this.step_count].path;
for (var p in path){
if (path.hasOwnProperty(p)){
this.polyline.push(path[p]);
}
}
this.step_count++;
}
};
};
// Geolocation (Modern browsers only)
GMaps.geolocate = function(options) {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
options.success(position);
if (options.always) {
options.always();
}
}, function(error) {
options.error(error);
if (options.always) {
options.always();
}
}, options.options);
}
else {
options.not_supported();
if (options.always) {
options.always();
}
}
};
// Geocoding
GMaps.geocode = function(options) {
this.geocoder = new google.maps.Geocoder();
var callback = options.callback;
if (options.hasOwnProperty('lat') && options.hasOwnProperty('lng')) {
options.latLng = new google.maps.LatLng(options.lat, options.lng);
}
delete options.lat;
delete options.lng;
delete options.callback;
this.geocoder.geocode(options, function(results, status) {
callback(results, status);
});
};
// Static maps
GMaps.staticMapURL = function(options){
var parameters = [];
var data;
var static_root = 'http://maps.googleapis.com/maps/api/staticmap';
if (options.url){
static_root = options.url;
delete options.url;
}
static_root += '?';
var markers = options.markers;
delete options.markers;
if (!markers && options.marker){
markers = [options.marker];
delete options.marker;
}
var polyline = options.polyline;
delete options.polyline;
/** Map options **/
if (options.center){
parameters.push('center=' + options.center);
delete options.center;
}
else if (options.address){
parameters.push('center=' + options.address);
delete options.address;
}
else if (options.lat){
parameters.push(['center=', options.lat, ',', options.lng].join(''));
delete options.lat;
delete options.lng;
}
else if (options.visible){
var visible = encodeURI(options.visible.join('|'));
parameters.push('visible=' + visible);
}
var size = options.size;
if (size){
if (size.join){
size = size.join('x');
}
delete options.size;
}
else {
size = '630x300';
}
parameters.push('size=' + size);
if (!options.zoom){
options.zoom = 15;
}
var sensor = options.hasOwnProperty('sensor') ? !!options.sensor : true;
delete options.sensor;
parameters.push('sensor=' + sensor);
for (var param in options){
if (options.hasOwnProperty(param)){
parameters.push(param + '=' + options[param]);
}
}
/** Markers **/
if (markers){
var marker, loc;
for (var i=0; data=markers[i]; i++){
marker = [];
if (data.size && data.size !== 'normal'){
marker.push('size:' + data.size);
}
else if (data.icon){
marker.push('icon:' + encodeURI(data.icon));
}
if (data.color){
marker.push('color:' + data.color.replace('#', '0x'));
}
if (data.label){
marker.push('label:' + data.label[0].toUpperCase());
}
loc = (data.address ? data.address : data.lat + ',' + data.lng);
if (marker.length || i === 0){
marker.push(loc);
marker = marker.join('|');
parameters.push('markers=' + encodeURI(marker));
}
// New marker without styles
else {
marker = parameters.pop() + encodeURI('|' + loc);
parameters.push(marker);
}
}
}
/** Polylines **/
function parseColor(color, opacity){
if (color[0] === '#'){
color = color.replace('#', '0x');
if (opacity){
opacity = parseFloat(opacity);
opacity = Math.min(1, Math.max(opacity, 0));
if (opacity === 0){
return '0x00000000';
}
opacity = (opacity * 255).toString(16);
if (opacity.length === 1){
opacity += opacity;
}
color = color.slice(0,8) + opacity;
}
}
return color;
}
if (polyline){
data = polyline;
polyline = [];
if (data.strokeWeight){
polyline.push('weight:' + parseInt(data.strokeWeight, 10));
}
if (data.strokeColor){
var color = parseColor(data.strokeColor, data.strokeOpacity);
polyline.push('color:' + color);
}
if (data.fillColor){
var fillcolor = parseColor(data.fillColor, data.fillOpacity);
polyline.push('fillcolor:' + fillcolor);
}
var path = data.path;
if (path.join){
for (var j=0, pos; pos=path[j]; j++){
polyline.push(pos.join(','));
}
}
else {
polyline.push('enc:' + path);
}
polyline = polyline.join('|');
parameters.push('path=' + encodeURI(polyline));
}
parameters = parameters.join('&');
return static_root + parameters;
};
//==========================
// Polygon containsLatLng
// https://github.com/tparkin/Google-Maps-Point-in-Polygon
// Poygon getBounds extension - google-maps-extensions
// http://code.google.com/p/google-maps-extensions/source/browse/google.maps.Polygon.getBounds.js
if (!google.maps.Polygon.prototype.getBounds) {
google.maps.Polygon.prototype.getBounds = function(latLng) {
var bounds = new google.maps.LatLngBounds();
var paths = this.getPaths();
var path;
for (var p = 0; p < paths.getLength(); p++) {
path = paths.getAt(p);
for (var i = 0; i < path.getLength(); i++) {
bounds.extend(path.getAt(i));
}
}
return bounds;
};
}
// Polygon containsLatLng - method to determine if a latLng is within a polygon
google.maps.Polygon.prototype.containsLatLng = function(latLng) {
// Exclude points outside of bounds as there is no way they are in the poly
var bounds = this.getBounds();
if (bounds !== null && !bounds.contains(latLng)) {
return false;
}
// Raycast point in polygon method
var inPoly = false;
var numPaths = this.getPaths().getLength();
for (var p = 0; p < numPaths; p++) {
var path = this.getPaths().getAt(p);
var numPoints = path.getLength();
var j = numPoints - 1;
for (var i = 0; i < numPoints; i++) {
var vertex1 = path.getAt(i);
var vertex2 = path.getAt(j);
if (vertex1.lng() < latLng.lng() && vertex2.lng() >= latLng.lng() || vertex2.lng() < latLng.lng() && vertex1.lng() >= latLng.lng()) {
if (vertex1.lat() + (latLng.lng() - vertex1.lng()) / (vertex2.lng() - vertex1.lng()) * (vertex2.lat() - vertex1.lat()) < latLng.lat()) {
inPoly = !inPoly;
}
}
j = i;
}
}
return inPoly;
};
google.maps.LatLngBounds.prototype.containsLatLng = function(latLng) {
return this.contains(latLng);
};
google.maps.Marker.prototype.setFences = function(fences) {
this.fences = fences;
};
google.maps.Marker.prototype.addFence = function(fence) {
this.fences.push(fence);
};
return GMaps;
}(this));
var arrayToLatLng = function(coords) {
return new google.maps.LatLng(coords[0], coords[1]);
};
var extend_object = function(obj, new_obj) {
if(obj === new_obj) return obj;
for(var name in new_obj){
obj[name] = new_obj[name];
}
return obj;
};
var array_map = function(array, callback) {
if (Array.prototype.map && array.map === Array.prototype.map) {
return array.map(callback);
} else {
var array_return = [];
var array_length = array.length;
for(var i = 0; i < array_length; i++) {
array_return.push(callback(array[i]));
}
return array_return;
}
}
}
/*Extension: Styled map*/
GMaps.prototype.addStyle = function(options){
var styledMapType = new google.maps.StyledMapType(options.styles, options.styledMapName);
this.map.mapTypes.set(options.mapTypeId, styledMapType);
};
GMaps.prototype.setStyle = function(mapTypeId){
this.map.setMapTypeId(mapTypeId);
};
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;
(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=
[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[geshifilter-c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c< f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&& (j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r= {b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length, t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b=== "string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g<d.length;++g)e(d[g]);m===(m|0)&&d[0].setAttribute("value", m);var r=s.createElement("OL");r.className="linenums";for(var n=Math.max(0,m-1|0)||0,g=0,z=d.length;g<z;++g)l=d[g],l.className="L"+(g+n)%10,l.firstChild||l.appendChild(s.createTextNode("\xa0")),r.appendChild(l);a.appendChild(r)}function k(a,m){for(var e=m.length;--e>=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*</.test(m)?"default-markup":"default-code";return A[a]}function E(a){var m= a.g;try{var e=M(a.h),h=e.a;a.a=h;a.c=e.c;a.d=0;C(m,h)(a);var k=/\bMSIE\b/.test(navigator.userAgent),m=/\n/g,t=a.a,s=t.length,e=0,l=a.c,p=l.length,h=0,d=a.e,g=d.length,a=0;d[g]=s;var r,n;for(n=r=0;n<g;)d[n]!==d[n+2]?(d[r++]=d[n++],d[r++]=d[n++]):n+=2;g=r;for(n=r=0;n<g;){for(var z=d[n],f=d[n+1],b=n+2;b+2<=g&&d[b+1]===f;)b+=2;d[r++]=z;d[r++]=f;n=b}for(d.length=r;h<p;){var o=l[h+2]||s,c=d[a+2]||s,b=Math.min(o,c),i=l[h+1],j;if(i.nodeType!==1&&(j=t.substring(e,b))){k&&(j=j.replace(m,"\r"));i.nodeValue= j;var u=i.ownerDocument,v=u.createElement("SPAN");v.className=d[a+1];var x=i.parentNode;x.replaceChild(v,i);v.appendChild(i);e<o&&(l[h+1]=i=u.createTextNode(t.substring(b,o)),x.insertBefore(i,v.nextSibling))}e=b;e>=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^<?]+/],["dec",/^<!\w[^>]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^<xmp\b[^>]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^<script\b[^>]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^<style\b[^>]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p<h.length&&l.now()<e;p++){var n=h[p],k=n.className;if(k.indexOf("prettyprint")>=0){var k=k.match(g),f,b;if(b= !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p<h.length?setTimeout(m, 250):a&&a()}for(var e=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")],h=[],k=0;k<e.length;++k)for(var t=0,s=e[k].length;t<s;++t)h.push(e[k][t]);var e=q,l=Date;l.now||(l={now:function(){return+new Date}});var p=0,d,g=/\blang(?:uage)?-([\w.]+)(?!\S)/;m()};window.PR={createSimpleLexer:x,registerLangHandler:k,sourceDecorator:u,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit", PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ"}})();?>
Это код страницы
<?php global $root; ?> <div id="map1"> </div> <!-- CONTACT CONTAINER --> <div class="container" style="background:url(<?php echo $root; ?>/img/stripes.png);"> <section class="row white"> </div> </div> </section> </div> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"> </script> <script src="<?php echo $root;?>/js/maps1.js"> </script> <script type="text/javascript"> //<![CDATA[ var map; jQuery(document).ready(function ($) { prettyPrint(); map = new GMaps({ div: '#map1', lat: 52.71964, lng: 41.437933, }); map.addMarker({ lat: 52.71964, lng: 41.437933, title: 'Фабрика «Мирта», г. Саранск, ул. Северная, 19а', click: function(e){ if(console.log) console.log(e); alert('You clicked in this marker'); } }); }); //]]> </script>
Код в СSS#map1{ height:700px; }
[/geshifilter-c]Я НАШЕЛ РЕШЕНИЕ... МОЖЕТ КОМУ ПРИГОДИТСЯ...
<?php global $root; ?>
<div id="map1">
</div>
<!-- CONTACT CONTAINER -->
<div class="container" style="background:url(<?php echo $root; ?>/img/stripes.png);">
<section class="row white">
</div>
</div>
</section>
</div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true">
</script>
<script src="<?php echo $root;?>/js/maps1.js">
</script>
<script type="text/javascript">
//<![CDATA[
var map;
jQuery(document).ready(function ($) {
prettyPrint();
map = new GMaps({
div: '#map1',
lat: 52.71964,
lng: 41.437933,
});
map.addMarker({
lat: 52.71964,
lng: 41.437933,
title: 'Фабрика «Мирта», г. Саранск, ул. Северная, 19а',
click: function(e){
if(console.log)
console.log(e);
alert('You clicked in this marker'); }
});
map.addMarker({
lat: 59.209,
lng: 39.8456,
title: 'Вологодская область, г. Вологда, ул. Ленинградская, 81, 3',
click: function(e){
if(console.log)
console.log(e);
alert('You clicked in this marker'); }
});
});
//]]>
</script>
?>
Я МАНАЛ. Нахера столько кода для вставки банальной карты? Это прикол что ли?