Welcome, Guest
Username: Password: Remember me

TOPIC: Google Map Marker.setDraggable

Google Map Marker.setDraggable 14 Jul 2016 01:42 #14236

  • vlemos
  • vlemos's Avatar
  • Online
  • Elite Member
  • Posts: 296
  • Thank you received: 41
  • Karma: 21
Needed the marker draggable and therefore updated map.js with the following lines.

var draggable = false;
if (typeof(mapObject.markers.draggable) != 'undefined')
draggable = mapObject.markers.draggable;

.
.
.
// set marker draggable property
marker.setDraggable(draggable);



Usage:
'markers' => array(
'draggable' => true,


Hope this helps someone working with this new cook feature.

Warm regards
vlemos


<?php echo JDom::_('html.fly.map.google', array(

	'keyAPI' => '<YOUR API KEY>',

	'request' => array(
		'zoom' => 4,
	),

	'markers' => array(
		'fitBounds' => true,

		'draggable' => true,

		'data' => array(
			array(

				// Australia
				'position' => array(
					'lat' => -25.363,
					'lng' => 131.044
				),

				'title' => 'Australia'
			),
		)
	),

)); ?>


IN: .../libraries/jdom/assets/google/js/map.js
// Instance the markers
if ((typeof(mapObject.markers) != 'undefined') && (typeof(mapObject.markers.data) != 'undefined'))
{
	var fitBounds = false;
	if (typeof(mapObject.markers.fitBounds) != 'undefined')
		fitBounds = mapObject.markers.fitBounds;

	if (fitBounds)
	{
		map._ck.bounds = new google.maps.LatLngBounds();
		map._ck.bounds = null;
	}

	var draggable = false;
	if (typeof(mapObject.markers.draggable) != 'undefined')
		draggable = mapObject.markers.draggable;

	// Global Icon sizes
	var iconSizeWidth = 20;
	if (typeof(mapObject.markers.iconWidth) != 'undefined')
		iconSizeWidth = mapObject.markers.iconWidth;

	var iconSizeHeight = 32;
	if (typeof(mapObject.markers.iconHeight) != 'undefined')
		iconSizeHeight = mapObject.markers.iconHeight;


	// Global Animations
	var animation = null;
	if (typeof(mapObject.markers.animation) != 'undefined')
		animation = google.maps.Animation['mapObject.markers.animation'];


	var markers = mapObject.markers.data;
	mapObject.markers.googleObject = [];
	var googleMarkers = mapObject.markers.googleObject;


	for (var i = 0 ; i < markers.length ; i++)
	{
		var markerData = markers[i];

		// Index the markers by id
		var idMarker = i;

		// Set the amimation
		if (animation)
			markerData.animation = animation;

		//Set the map to the data
		markerData.map = map;

		if (typeof(markerData.icon) != 'undefined')
		{

			// Get special sizes for every single marker
			var iconWidth = iconSizeWidth;
			if (typeof(markerData.iconWidth) != 'undefined')
				iconWidth = markerData.iconWidth;

			var iconHeight = iconSizeHeight;
			if (typeof(markerData.iconHeight) != 'undefined')
				iconHeight = markerData.iconHeight;



			markerData.icon = new google.maps.MarkerImage(markerData.icon,
				new google.maps.Size(iconWidth, iconHeight),
				new google.maps.Point(0,0),
				new google.maps.Point(0, 32)
			);
		}

		// Optimization : Don't sent the content string to the marker constructor
		var contentString = null;
		if (typeof(markerData.content) != 'undefined')
		{
			contentString = markerData.content;
			markerData.content = null;
		}

		// Create the marker
		var marker = new google.maps.Marker(markerData);

		// set marker draggable property
		marker.setDraggable(draggable);

		// Store the Google Object in order to keep it in the memory, and not be destroyed by the garbage colector.
		googleMarkers[idMarker] = marker;
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Google Map Marker.setDraggable 14 Jul 2016 07:07 #14240

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
=> GitHub
Coding is now a piece of cake
The administrator has disabled public write access.

Google Map Marker.setDraggable 14 Jul 2016 09:02 #14243

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Basicaly, it is easy to make it draggable.
The only thing, is then to populate the desired fields, so this code is incomplete.

Don't worry it is gonna come but later. I know if you are not able to save latitude / longitude it is really incomplete because you will always need the geocoding by address, but the idea is also to geocode a list of items from a list and populate the positions in mass.

I working on that, but be patient. That why the best is to use GitHub if you want it faster. Otherwise you will need to wait.
Google Map plugin is not finished.

Also, a good point would be to put the bases also for Open Streets. Because on my philosophy I want to propose both in the same time in the builder. With the same structure of datas (abstraction). Only the map styling will be non-abstracted. (Specific for each engine).

Anyways, thanks veronica for all your proposals and for all your investments. This is highly welcome.
K++
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: vlemos
Time to create page: 0.082 seconds

Get Started