Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- case "6": {$address = $_SESSION['mylocation']['address']; // GOOGLE MAP ?>
- <div id="showmapbox">
- <input name="custom[map_location]" id="form_map_location" class="controls" type="text" placeholder="<?php echo $address ?>" value="<?php echo $address /*echo get_post_meta($_GET['eid'],'map_location',true)*/?>" />
- <div id="wlt_map_location" style="height:300px;width:100%;"></div>
- <div class="well well-sm">
- <b><?php echo $CORE->_e(array('add','46')); ?></b>
- <?php echo $CORE->_e(array('add','47')); ?>: <span id="wlt_dcountry" class="label label-primary"><?php if(isset($_GET['eid']) && get_post_meta($_GET['eid'],'map-country',true) != ""){ echo get_post_meta($_GET['eid'],'map-country',true); }else{ echo '<i class="glyphicon glyphicon-remove"></i>'; } ?></span>
- <?php echo $CORE->_e(array('add','48')); ?>: <span id="wlt_dstate" class="label label-primary"><?php if(isset($_GET['eid']) && get_post_meta($_GET['eid'],'map-state',true) != ""){ echo get_post_meta($_GET['eid'],'map-state',true); }else{ echo '<i class="glyphicon glyphicon-remove"></i>'; } ?></span>
- <?php echo $CORE->_e(array('add','49')); ?>: <span id="wlt_dcity" class="label label-primary"><?php if(isset($_GET['eid']) && get_post_meta($_GET['eid'],'map-city',true) != ""){ echo get_post_meta($_GET['eid'],'map-city',true); }else{ echo '<i class="glyphicon glyphicon-remove"></i>'; } ?></span>
- </div>
- </div>
- <input type="hidden" id="map-long" name="custom[map-log]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-log',true).'"'; } ?>>
- <input type="hidden" id="map-lat" name="custom[map-lat]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-lat',true).'"'; } ?>>
- <input type="hidden" id="map-country" name="custom[map-country]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-country',true).'"'; } ?>>
- <input type="hidden" id="map-address1" name="custom[map-address1]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-address1',true).'"'; } ?>>
- <input type="hidden" id="map-address2" name="custom[map-address2]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-address2',true).'"'; } ?>>
- <input type="hidden" id="map-address3" name="custom[map-address3]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-address3',true).'"'; } ?>>
- <input type="hidden" id="map-zip" name="custom[map-zip]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-zip',true).'"'; } ?>>
- <input type="hidden" id="map-state" name="custom[map-state]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-state',true).'"'; } ?>>
- <input type="hidden" id="map-city" name="custom[map-city]" <?php if(isset($_GET['eid'])){ echo 'value="'.get_post_meta($_GET['eid'],'map-city',true).'"'; } ?>>
- <script type="text/javascript">
- var geocoder;var map;var marker = ''; var markers = [];
- function initialize() {
- if(typeof(map) != "undefined"){ return; }
- // GET DEFAULT LOCATION
- <?php if(isset($_GET['eid']) && get_post_meta($_GET['eid'],'map-log',true) !=""){
- $DF_LOCATON = get_post_meta($_GET['eid'],'map-lat',true).",".get_post_meta($_GET['eid'],'map-log',true);
- }else{
- $DF_LOCATON = $GLOBALS['CORE_THEME']['google_coords'];
- }
- if($DF_LOCATON == ""){ $DF_LOCATON ="0,0"; }
- $DF_ZOOM = $GLOBALS['CORE_THEME']['google_zoom'];
- if($DF_ZOOM == ""){ $DF_ZOOM = "5"; }
- ?>
- // CREATE MAP CANVUS
- var myOptions = {mapTypeId: google.maps.MapTypeId.ROADMAP, zoomControl: true, scaleControl: true }
- map = new google.maps.Map(document.getElementById("wlt_map_location"), myOptions);
- // LOAD MAP LOCATIONS
- var defaultBounds = new google.maps.LatLngBounds(
- new google.maps.LatLng(<?php echo $DF_LOCATON; ?>) );
- map.fitBounds(defaultBounds);
- // ADD ON MARKER
- <?php if(isset($_GET['eid']) && get_post_meta($_GET['eid'],'map-log',true) !=""){ ?>
- var marker = new google.maps.Marker({
- position: new google.maps.LatLng(<?php echo get_post_meta($_GET['eid'],'map-lat',true); ?>,<?php echo get_post_meta($_GET['eid'],'map-log',true); ?>),
- map: map,
- animation: google.maps.Animation.DROP,
- icon: new google.maps.MarkerImage('<?php echo get_template_directory_uri(); ?>/framework/img/map/icon.png'),
- });
- <?php } ?>
- // ADD SEARCH BOX
- map.controls[google.maps.ControlPosition.TOP_LEFT].push(document.getElementById('form_map_location'));
- var searchBox = new google.maps.places.SearchBox(document.getElementById('form_map_location'));
- // EVENT
- google.maps.event.addListener(searchBox, 'places_changed', function() {
- var places = searchBox.getPlaces();
- if (places.length == 0) {
- return;
- }
- for (var i = 0, marker; marker = markers[i]; i++) {
- marker.setMap(null);
- }
- // For each place, get the icon, place name, and location.
- var bounds = new google.maps.LatLngBounds();
- for (var i = 0, place; place = places[i]; i++) {
- var image = {
- url: place.icon,
- size: new google.maps.Size(71, 71),
- origin: new google.maps.Point(0, 0),
- anchor: new google.maps.Point(17, 34),
- scaledSize: new google.maps.Size(25, 25)
- };
- addMarker(place.geometry.location);
- document.getElementById("map-long").value = place.geometry.location.lng();
- document.getElementById("map-lat").value = place.geometry.location.lat();
- getMyAddress(place.geometry.location,true)
- bounds.extend(place.geometry.location);
- }
- map.fitBounds(bounds);
- map.setZoom(12);
- });
- // EVENT
- google.maps.event.addListener(map, 'bounds_changed', function() {
- var bounds = map.getBounds();
- searchBox.setBounds(bounds);
- });
- // EVENT
- google.maps.event.addListener(map, 'click', function(event){
- document.getElementById("map-long").value = event.latLng.lng();
- document.getElementById("map-lat").value = event.latLng.lat();
- getMyAddress(event.latLng,"yes");
- addMarker(event.latLng);
- });
- // DEFAULT ZOOM LEVEL
- var listener = google.maps.event.addListener(map, "idle", function() {
- if (map.getZoom() != <?php echo $DF_ZOOM; ?>){ map.setZoom(<?php echo $DF_ZOOM; ?>); }
- google.maps.event.removeListener(listener);
- });
- } // END INIT
- jQuery("#form_map_location").focusout(function() {
- setTimeout(function(){ getMapLocation(jQuery("#form_map_location").val()); }, 500);
- });
- function getMapLocation(location){
- document.getElementById("map-state").value = "";
- var geocoder = new google.maps.Geocoder();
- if (geocoder) { geocoder.geocode({"address": location}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) {
- map.setCenter(results[0].geometry.location);
- addMarker(results[0].geometry.location);
- getMyAddress(results[0].geometry.location,"no");
- document.getElementById("map-long").value = results[0].geometry.location.lng();
- document.getElementById("map-lat").value = results[0].geometry.location.lat();
- map.setZoom(<?php $default_zoom = $GLOBALS['CORE_THEME']['google_zoom']; if($default_zoom == ""){ $default_zoom = "9"; } echo $default_zoom; ?>);
- }});}
- }
- function getMyAddress(location,setaddress){
- jQuery('#showmapbox').show();
- google.maps.event.trigger(map, 'resize');
- var geocoder = new google.maps.Geocoder();
- var country = "";
- if (geocoder) {geocoder.geocode({"latLng": location}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) {
- for (var i = 0; i < results[0].address_components.length; i++) {
- var addr = results[0].address_components[i];
- //alert(addr.types[0]);
- switch (addr.types[0]){
- case "street_number": {
- document.getElementById("map-address1").value = addr.long_name;
- } break;
- case "route": {
- document.getElementById("map-address2").value = addr.long_name;
- } break;
- case "locality":
- //case "postal_town":
- {
- document.getElementById("map-address3").value = addr.long_name;
- document.getElementById("map-city").value = addr.long_name;
- } break;
- case "postal_code": {
- document.getElementById("map-zip").value = addr.short_name;
- } break;
- case "administrative_area_level_1": {
- document.getElementById("map-state").value = addr.long_name;
- } break;
- case "administrative_area_level_2": {
- document.getElementById("map-state").value = addr.long_name;
- } break;
- case "administrative_area_level_3": {
- document.getElementById("map-state").value = document.getElementById("map-state").value + addr.long_name;
- } break;
- case "country": {
- document.getElementById("map-country").value = addr.short_name;
- } break;
- } // end switch
- } // end for
- // NOW SET THE DISPLAY VALUES
- jQuery('#wlt_dcity').html(document.getElementById("map-city").value);
- jQuery('#wlt_dstate').html(document.getElementById("map-state").value);
- jQuery('#wlt_dcountry').html(document.getElementById("map-country").value);
- if(setaddress == "yes"){
- document.getElementById("form_map_location").value = results[0].formatted_address;
- }
- map.setCenter(results[0].geometry.location);
- map.setZoom(15);
- } }); }}
- function addMarker(location) {
- if (marker=='') {
- marker = new google.maps.Marker({ position: location, map: map, draggable:true, animation: google.maps.Animation.DROP, });
- google.maps.event.addListener (marker, 'dragend', function (event){
- document.getElementById("map-long").value = event.latLng.lng();
- document.getElementById("map-lat").value = event.latLng.lat();
- getMyAddress(event.latLng,"yes");
- addMarker(event.latLng);
- });
- }
- marker.setPosition(location);
- map.setCenter(location);
- }
- <?php if($DISPLAYSTYLE == "small"){ ?>
- // LOAD MAP BOX
- jQuery(document).ready(function() {
- setTimeout(function(){ initialize(); }, 1000);
- });
- <?php }else{ ?>
- // LOAD MAP BOX
- jQuery(document).ready(function() {
- jQuery( ".mapboxlink" ).click(function() {
- setTimeout(function(){ initialize(); }, 1000);
- });
- });
- <?php } ?>
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement