Gmap Editor

Ερωτήσεις και απαντήσεις σχετικές με την HTML, XHTML και την κατασκευή σελίδων για το Web.

Συντονιστές: WebDev Moderators, Super-Moderators

Απάντηση
Intefix
Δημοσιεύσεις: 186
Εγγραφή: 22 Σεπ 2007 16:21
Τοποθεσία: Ηράκλειο Κρήτης
Επικοινωνία:

Gmap Editor

Δημοσίευση από Intefix » 02 Ιουν 2010 19:48

Εικόνα

Αλλάξτε api key και παραμέτρους...

Κώδικας: Επιλογή όλων

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http&#58;//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http&#58;//www.w3.org/1999/xhtml"
      xmlns&#58;v="urn&#58;schemas-microsoft-com&#58;vml" style="height&#58;100%">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7" />
    <title>Gmap Editor</title>

    <script src="http&#58;//www.google.com/jsapi?key=<?php echo $this->google_api_key; ?>&amp;hl=<?php echo $this->gmap_lang; ?>"
      type="text/javascript"></script>

    <link rel="stylesheet" type="text/css" href="<?php echo $this->assetpath . '/css/gmap.css'; ?>"></link>


    <script type="text/javascript">
    //<!&#91;CDATA&#91;

        google.load&#40;"mootools", "1.2.3"&#41;;
        google.load&#40;"maps", "2.s"&#41;;

		// GeoContent item id
		var geocontent_id = '<?php echo $this->id; ?>';
        // Make it global&#58; the map object
        var map;
        // MBR
        var bounds ;
        // The geom feature list
        var feature_list = &#91;&#93;;
        // Start feature
        var geodata = '<?php echo str_replace&#40;"\n", ' ', $this->item->geodata&#41;; ?>';
        // Application status
        var application_status = 'nodata';
        // style
        var layer_style = &#123;linergba &#58; '#<?php echo $this->linergba; ?>', linewidth &#58; <?php echo $this->linewidth; ?>, polyrgba &#58; '#<?php echo $this->polyrgba; ?>', icon&#58; '<?php echo JURI&#58;&#58;root&#40;&#41; . 'images/'.$this->point_icon_folder .'/' . $this->icon; ?>', iconsize &#58; <?php echo $this->iconsize; ?>&#125;;


        function OnLoad&#40;&#41; &#123;
            // Features MBR
            bounds = new google.maps.LatLngBounds&#40;&#41;;
           // Map setup
            GPolygon.prototype.WKT = 'POLYGON';
            GPolygon.prototype.CLASSNAME = 'GPolygon';

            GPolyline.prototype.WKT = 'LINESTRING';
            GPolyline.prototype.CLASSNAME = 'GPolyline';

            GMarker.prototype.WKT = 'POINT';
            GMarker.prototype.CLASSNAME = 'GMarker';
            map = new google.maps.Map2&#40;document.getElementById&#40;"map_canvas"&#41;&#41;;
            map.setCenter&#40;new google.maps.LatLng&#40;<?php echo $this->gmap_latstart; ?>, <?php echo $this->gmap_lngstart; ?>&#41;, <?php echo $this->gmap_zoomstart; ?>&#41;;
            map.addMapType&#40;G_PHYSICAL_MAP&#41;;
            map.removeMapType&#40;G_HYBRID_MAP&#41;;
            map.addControl&#40;new GMapTypeControl&#40;&#41;&#41;;
            if&#40;map.getSize&#40;&#41;.width > 400&#41; &#123;
                map.addControl&#40;new google.maps.OverviewMapControl&#40;&#41;&#41;;
                map.addControl&#40;new google.maps.LargeMapControl&#40;&#41;&#41;;
            &#125; else &#123;
                map.addControl&#40;new google.maps.SmallMapControl&#40;&#41;&#41;;
            &#125;
            map.enableScrollWheelZoom&#40;&#41;;
            buttonSelect&#40;"hand_b"&#41;;
            // Get startup parameters

            // Install delete handler
            google.maps.Event.addListener&#40;map, "click", function&#40;ol&#41; &#123;
                    if&#40;ol && $&#40;'delete_b'&#41;.hasClass&#40;'selected'&#41;&#41;&#123;
                        try &#123;
                            if&#40;ol.WKT != 'POINT'&#41;&#123;
                                ol.disableEditing&#40;&#41;;
                            &#125;
                            map.removeOverlay&#40;ol&#41;;
                            GEvent.clearInstanceListeners&#40;ol&#41;;
                            buttonSelect&#40;"hand_b"&#41;;
                        &#125; catch&#40;e&#41; &#123;&#125;
                    &#125;
            &#125;&#41;;

            // Install list handler
            google.maps.Event.addListener&#40;map, "addoverlay", function&#40;ol&#41; &#123;
                //console.log&#40;'addoverlay event fired'&#41;;
                if&#40;typeof ol.WKT !== 'undefined'&#41;&#123;
                    feature_list.push&#40;ol&#41;;
                    //console.log&#40;'added ' + ol.WKT&#41;;
                &#125;
            &#125;&#41;;


            // Install delete handler
            google.maps.Event.addListener&#40;map, "removeoverlay", function&#40;ol&#41; &#123;
                if&#40;typeof ol.WKT !== 'undefined'&#41;&#123;
                    feature_list.erase&#40;ol&#41;;
                    //console.log&#40;'removed ' + ol.WKT&#41;;
                &#125;
            &#125;&#41;;

            // Load WKT data
            if&#40;geodata&#41;&#123;
                var parser = new GFormatWKT&#40;editHandlerCb&#41;;
                parser.read&#40;geodata&#41;;
                map.setZoom&#40;map.getBoundsZoomLevel&#40;bounds&#41;&#41;;
                map.setCenter&#40;bounds.getCenter&#40;&#41;&#41;;
                setStatus&#40;'editing'&#41;;
            &#125; else &#123;
                map.setCenter&#40;new google.maps.LatLng&#40;<?php echo $this->gmap_latstart; ?>, <?php echo $this->gmap_lngstart; ?>&#41;, <?php echo $this->gmap_zoomstart; ?>&#41;;
                setStatus&#40;'nodata'&#41;;
            &#125;
        &#125;

        function save_feature_list&#40;&#41;&#123;
            var parser = new GFormatWKT&#40;editHandlerCb&#41;;
            bounds = new google.maps.LatLngBounds&#40;&#41;;
            var wkt = parser.write&#40;feature_list&#41;;
			var options = &#123;&#125;;
			options.method = 'post';
			options.url = '<?php echo $this->saveurl; ?>';
			options.onComplete = function&#40;response&#41; &#123;
				// Item deleted
				if&#40;!wkt && !document.geocontent_form.gpx&#41; &#123;
					geocontent_id = '';
				&#125;
				// Get the geocontent_id
				var m = response.match&#40;/#&#40;\d+&#41;/&#41;;
				if&#40;m&#41;&#123;
					geocontent_id = m&#91;1&#93;;
				&#125;
				alert&#40;response&#41;;
			&#125;;

			var myRequest = new Request&#40;options&#41;.send&#40;
				'geodata=' + wkt
				+'&minlat=' + bounds.getSouthWest&#40;&#41;.lat&#40;&#41;
				+'&minlon=' + bounds.getSouthWest&#40;&#41;.lng&#40;&#41;
				+'&maxlat=' + bounds.getNorthEast&#40;&#41;.lat&#40;&#41;
				+'&maxlon=' + bounds.getNorthEast&#40;&#41;.lng&#40;&#41;
				+'&layerid=<?php echo $this->layerid; ?>'
				+'&id=' + geocontent_id
				+'&contentid=<?php echo $this->contentid; ?>'
				+'&contentname=<?php echo urlencode&#40;$this->contentname&#41;; ?>'
				+ '&<?php echo JUtility&#58;&#58;getToken&#40;&#41;; ?>=1'

			&#41;;
        &#125;

        function quit&#40;&#41;&#123;
            if&#40;window.opener&#41;&#123;
                window.close&#40;this&#41;;
            &#125;
        &#125;

        // Set onload cb
        google.setOnLoadCallback&#40;OnLoad&#41;;

    //&#93;&#93;>
	</script>

    <script src="<?php echo $this->assetpath . '/js/gmap_edit.js'; ?>"      type="text/javascript"></script>
    <script src="<?php echo $this->assetpath . '/js/gmap_wkt.js'; ?>"      type="text/javascript"></script>

  </head>
  <body style="height&#58;100%;margin&#58;0">
    <div id="map_canvas" style="height&#58;100%;width&#58;<?php echo &#40;$this->has_editing ? '75%;float&#58;left' &#58; '100%'&#41;; ?>"></div>

    <div id="map_sidebar" style="height&#58;100%;width&#58;25%;float&#58;right">

        <div id="edit_controls" style="margin&#58;0.25em;padding&#58;0.25em;overflow&#58;auto">
            <strong><?php  echo JText&#58;&#58;_&#40;'Edit'&#41;;  ?>&nbsp;<button onclick="save_feature_list&#40;&#41;"><?php echo JText&#58;&#58;_&#40;'Save'&#41;; ?></button></strong>
            <table>
                <tr>
                    <td><div id="hand_b"        onclick="stopEditing&#40;&#41;"/></td>
                    <td><div id="placemark_b"   onclick="placeMarker&#40;&#41;"/></td>
                    <td><div id="line_b"        onclick="startLine&#40;&#41;"/></td>
                    <td><div id="shape_b"       onclick="startShape&#40;&#41;"/></td>
                    <td><div id="delete_b"      onclick="deleteShape&#40;&#41;"/></td>
                </tr>
            </table>

            <input type="hidden" id="featuredetails" rows="2"/>
            <p><?php echo JText&#58;&#58;_&#40;'GMAP_EDIT_MSG'&#41;; ?>
            </p>
            <table id ="featuretable">
                <tbody id="featuretbody"></tbody>
            </table>
        </div>

        <div id="file_controls" style="margin&#58;0.25em;padding&#58;0.25em;overflow&#58;auto">
            <atrong><?php echo JText&#58;&#58;_&#40;'Load GPX track'&#41;; ?></strong>
			<form method="post" name="geocontent_form" enctype="multipart/form-data">
			<input type="hidden" name="layerid" value="<?php echo $this->layerid; ?>" />
			<input type="hidden" name="id" value="<?php echo $this->id; ?>" />
			<input type="hidden" name="contentname" value="<?php echo urlencode&#40;$this->contentname&#41;; ?>" />
			<?php echo JHTML&#58;&#58;_&#40; 'form.token' &#41;; ?>
            <table>
                <tr><td><input size="10" type="file" name="gpx" id="gpx" /></td></tr>
                <tr><td><input type="submit" name="load" value="<?php echo JText&#58;&#58;_&#40;'Load'&#41;; ?>" id="load" /></td></tr>
            </table>
            </form>
        </div>
    </div>
  </body>
</html>

Απάντηση

Επιστροφή στο “HTML και XHTML”

Μέλη σε σύνδεση

Μέλη σε αυτήν τη Δ. Συζήτηση: Δεν υπάρχουν εγγεγραμμένα μέλη και 4 επισκέπτες